Jump to content

Move file/folder from desktop to another folder


Recommended Posts

hi guys,

I made this to move the screenshot file. Because when after doing a screenshot, the file immediately appears on the desktop and it is very annoying

make sure you already install https://alfred.app/workflows/alfredapp/shortcuts/  

  1. Open Automator
  2. Choose Application
  3. Search library Run AppleScript, drag n drop to the empty space on the right
  4. Type in the following code:
Quote

on run {input, parameters}

-- Define the source and destination folders

set sourceFolder to (path to desktop folder as text)

set destinationFolder to (path to pictures folder as text)

 

-- Get the list of files in the source folder

tell application "Finder"

set fileList to every file in folder sourceFolder whose name contains "Screenshot" and name extension is "png"

 

-- Move each file to the destination folder

repeat with i from 1 to number of items in fileList

set thisFile to item i of fileList

move thisFile to folder destinationFolder

end repeat

end tell

 

return input

end run

      5. Save wherever you want

      6. Open Shortcuts

      7. Drag n drop the automator file that was created earlier to shortcuts

      8. Run it from Alfred.

 

NOTE: you can modify the function at will, customise it to your needs.

• set sourceFolder to (path to desktop folder as text): Sets the source folder to the Desktop.

• set destinationFolder to (path to pictures folder as text): Sets the destination folder to Pictures.

• tell application "Finder": Tells Finder to perform the actions.

• set fileList to every file in folder sourceFolder whose name contains "Screenshot" and name extension is "png": Gets a list of files in the source folder that have “Screenshot” in their names and have a “.png” extension.

• repeat with i from 1 to number of items in fileList: Loops through each file in the list.

• set thisFile to item i of fileList: Sets the current file.

• move thisFile to folder destinationFolder: Moves the current file to the destination folder.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...