Hi,
Every day I have a bunch of files in the format below:
1007117pm.mp4 – Stands for Oct 7th 2011 7pm
1007116pm.mp4
1007115pm.mp4
0817111pm.mp4 – Stands for Aug 17th 2011 11pm
0816111pm.mp4
08161111am.mp4
08161110am.mp4
The script below will:
- User chooses folder of files
- Goes thru list of files in the folder & creates a folder based on the filename
- Moves associated file into it’s new folder
My problem is that I need the script to create only one folder for all files that
are named for the same date.
So using the filenames listed above:
(there would only be one folder for the following dates)
100711 – so all mp4 files for that day go in here
081711 – so all mp4 files for that day go in here
081611 – so all mp4 files for that day go in here
– here is the script / Any help in the right direction is appreciated
Thanks for taking a look.
set chosen_folder to (choose folder)
tell (a reference to my text item delimiters) to set {old_delim, contents} to {contents, "."}
tell application "Finder"
try
set file_list to files of chosen_folder
on error
set file_list to {}
end try
repeat with this_file in file_list
set folder_name to name of this_file
if folder_name contains "." then set folder_name to ((text items 1 thru -2 of folder_name) as string)
set new_folder to ((chosen_folder as string) & folder_name & ":")
try
get new_folder as alias
on error
make new folder at chosen_folder with properties {name:folder_name}
end try
move this_file to folder new_folder
end repeat
end tell
set my text item delimiters to old_delim