I have one large folder with thousands of mp3 files.
I want to create sub folders and move the mp3 files to these folders.
I have a CSV file that have all file names and info about what folder to add the file to.
CSV file looks like this. Note that some folders will contain several files.
set baseDir to "" & (choose folder with prompt "Please choose the baseFolder to operate on.")
set theCsvArray to paragraphs of (read (choose file))
set ASTID to AppleScript's text item delimiters
repeat with i from 1 to count of theCsvArray
try
set theItem to item i of theCsvArray
set AppleScript's text item delimiters to ","
set fileName to text 2 thru -2 of (text item 1 of theItem)
set folderName to text 2 thru -2 of (text item 2 of theItem)
set newFolder to baseDir & folderName
do shell script "mkdir -p " & quoted form of POSIX path of newFolder
set oldFile to baseDir & fileName
set newFile to baseDir & folderName & ":" & fileName
do shell script "mv -f " & quoted form of POSIX path of oldFile & space & quoted form of POSIX path of newFile
on error e
display dialog e giving up after 5
end try
end repeat
set AppleScript's text item delimiters to ASTID