I wanted to have an AppleScript application, that takes all the files from a specific Source-Folder and moves* them to a user defined Target-Folder.
After searching my way through different Discussion Boards and the official AppleScript Language Guide, I came up with the following working piece of code:
tell application "Finder" activate set source_folder to choose folder with prompt "Please choose the Source-Folder:" default location ((path to home folder) as alias) set source_files to every file in source_folder set target_folder to choose folder with prompt "Please choose the Taget-Folder:" default location (":Applications:" as alias) repeat with i from 1 to number of items in source_files set source_file to (item i of source_files) move source_file to (target_folder) -- use "copy source_file to folder (target_folder as alias)" to copy the files end repeat set question to display dialog " Files have been moved.
If you want to do a copy, instead of moving the files, change the line
move source_file to (target_folder)
to
copy source_file to folder (target_folder as alias)
Sources used
- MacUser.de discussion about “Move Files using AppleScript” (DE)
- MacUser.de discussion about “Copy Files using AppleScript” (DE)
- Mac Rumors discussion about “AppleScript get list of Files”
- Apple’s official “AppleScript Language Guide”
Hallo Oliver,
das Script spart Zeit – hast du ev. eine Idee das ganze in Kombi mit Automator und vor der erweiterten Aufgabenstellung:
– finde alle neue Dateien mit dem Namensteil ttt im Laufwerk XX
– bewege diese auf das Laufwerk YY mit gleicher Verzeichnisstruktur vom Laufwerk XX
…
bin gespannt
Grüße
Jörg
Hello,
I am getting the following error when I run this script:
“`Syntax Error
Expected string but found end of script.“`
Please let me know what could be causing this. Thank you and have a great day! 🙂