Hi,
I am totally useless scripting, so i hope you can help. I got this script from macscripter.com and i can not get the **** thing to work, seems to only pick up the first filename in the CSV and leave the rest, what is missing?
I have 300 files to match and this will save me a whole bunch of a head ache. please help.
I am using EL Captain, maybe there is something that has in AppleScript in this version?
so if a CSV has the below
fileX2.png
fileY2.png
the script seems to only pick the first CSV value fileX2.png even though the other fileY2.png is in the folder.
I am totally useless scripting, so i hope you can help. I got this script from macscripter.com and i can not get the **** thing to work, seems to only pick up the first filename in the CSV and leave the rest, what is missing?
I have 300 files to match and this will save me a whole bunch of a head ache. please help.
I am using EL Captain, maybe there is something that has in AppleScript in this version?
Code:
--Sur la Table script for copying files to a new location using a CSV file as source.
--This script assumes the following:
-- The CSV file contains no empty cells and no erroneous filenames
-- The files indicated in the CSV file are actually located in the SOURCE folder
tell application "Finder"
activate
--CODE for getting the INFO from a file
set CSV_source_File to choose file with prompt "Select the CSV file containing the filenames you need to find and duplicate." without invisibles
set OldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {return} --this MUST be return when using CSV files
--CODE telling the script to make a list from the selected file.
set Source_List to every text item of (read CSV_source_File as string)
set AppleScript's text item delimiters to OldDelims
--CODE for choosing your SOURCE:
set Source_Folder to choose folder with prompt "Choose SOURCE FOLDER of files." & return & "(Files here that match the filenames in your CSV file" & return & "will be duplicated to a new TARGET location.)" without invisibles
--display dialog "You have chosen SOURCE FOLDER:" & return & Source_Folder -- this is just feedback and can be deleted
set Source_Folder_full_list to files of entire contents of Source_Folder
--CODE for choosing your TARGET:
set Target_Folder to choose folder with prompt "Choose a TARGET FOLDER to duplicate the SOURCE files to." & return & return & "The count of files to be duplicated is " & return & (count of Source_List) & return & "Please check the folder when done." without invisibles
--display dialog "You have chosen TARGET FOLDER:" & return & Target_Folder -- this is just feedback and can be deleted
--Here's the meat of it:
repeat with i from 1 to (count Source_Folder_full_list)
set file_source_One to item i of Source_Folder_full_list
set file_source_OneName to name of file_source_One
if (file_source_OneName is in Source_List) then
duplicate file_source_One to Target_Folder with replacing
end if
end repeat
beep 1
display dialog "All files were duplicated as requested." giving up after 3
end tell
so if a CSV has the below
fileX2.png
fileY2.png
the script seems to only pick the first CSV value fileX2.png even though the other fileY2.png is in the folder.
Last edited: