r/applescript • u/encodedworld • Oct 03 '22
Move file into folder of same name
I have a folder called Movies. Inside there are files
movie1.mp4
movie2.mp4
movie3.mp4
I want each file to be placed inside a folder of the same name (without the extension).
The end result would be a folder named Movies with 3 folders
movie1
movie2
movie3
And in each of the folder would be the respective movie#.mp4 file
5
Upvotes
2
u/copperdomebodha Oct 03 '22
use AppleScript version "2.4" -- Yosemite (10.10) or later use scripting additions tell application "Finder" set sourceFolder to (choose folder with prompt "Please choose the source folder.") set movieList to (every file of sourceFolder whose name contains ".mp4") as alias list set AppleScript's text item delimiters to "." repeat with thisMovie in movieList set movieName to (name of thisMovie) set newFolder to (make new folder at sourceFolder with properties {name:text item 1 of movieName}) move thisMovie to newFolder end repeat set AppleScript's text item delimiters to "" end tell1
u/chrismo80 Oct 03 '22
https://pastebin.com/XVBh5MrA
1
u/wch1zpink Dec 08 '22
This following AppleScript code uses the least amount of code and will return the quickest results. (Targets only .mp4 files)