Skip to content

Instantly share code, notes, and snippets.

Created December 23, 2013 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/a859011240ce09f17069 to your computer and use it in GitHub Desktop.
Save anonymous/a859011240ce09f17069 to your computer and use it in GitHub Desktop.
Välj den mapp där du har alla dina pdf filer. Förslagsvis testar du med en backup innan :
set loc to choose folder
tell application "Finder"
set filelist to every file of loc
repeat with file_ in filelist
set file_name to name of file_
set AppleScript's text item delimiters to {"|", "."}
try
set old_file_path to POSIX path of loc & file_name
set new_folder_name to second text item of file_name
set new_file_name to third text item of file_name & "." & fourth text item of file_name
set new_folder_path to POSIX path of loc & new_folder_name
set new_file_path to POSIX path of loc & new_folder_name & "/" & new_file_name
set new_creation_date to first text item of file_name
set new_sub_creation_date to text 1 thru -3 of new_creation_date & "." & text -2 thru -1 of new_creation_date
do shell script "mkdir -p " & quoted form of new_folder_path
do shell script "mv -f " & quoted form of old_file_path & " " & quoted form of new_file_path
do shell script "touch -t " & new_sub_creation_date & " " & quoted form of new_file_path
end try
end repeat
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment