Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Move files to folders depending if they are in a list

Hi I am trying to wrote a script that checks if the item is in list A (CSV) if in list A move to Folder A else move to Folder B.


It would be moving images around so would need to disregard the extension.

Also Filenames are in the form AB10WW01234BU1SL 16 characters long. Some of the shots have more than one image and have this added _2, _3 etc. if the first part of the name is in the list then it still needs to be moved to the relevant folder.


I've been searching the net but not yet finding anything suitable,


Matt

iMac, OS X Mavericks (10.9.4)

Posted on Oct 13, 2015 2:17 AM

Reply
1 reply

Oct 13, 2015 2:36 AM in response to MattJayC

I might have been trying to hard.


I have this, and so far so good


property csvAlias : alias (((path to home folder) as text) & "DropBox:Checklists:WeekA.csv")

property this_folder : alias (((path to desktop) as text) & "Hotfolder2")

property folderA : alias (((path to pictures folder) as text) & "WeekA")

property folderB : alias (((path to pictures folder) as text) & "WeekB")



tell application "Finder"


--set this_folder to folder "HotFolder" as alias

set itemList to every file in this_folder

end tell



repeat with i from 1 to count of itemList

set newFile to itemi of itemList

tell application "System Events" to set {fSuffix, fName} to {(name extension of disk item (newFile as text)), (displayed name of disk item (newFile as text))}

set itemName to (text 1 thru 16 of fName)


logitemName


set csvText to readcsvAlias


if csvText contains itemName then


movenewFiletofolderA

else


movenewFiletofolderB

end if


end repeat

Move files to folders depending if they are in a list

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.