I have a folder with many sub folders, all containing files with random numbers attached before the actual files name. For example:
1-04-5 File name 1
23-2-1 File name 2
002-1-93 File name 3
ETC…
I was wondering if there was a way to go through each file and just delete everything in the file name until it hits the first letter of the first word, starting from the left.
For Example:
1-04-5 File name 1 23-2-1 File name 2 002-1-93 File name 3
ETC…
assuming that all file names have the same syntax (the first space character is the delimiter) try this
set SourceFolder to POSIX path of (choose folder with prompt "Choose source folder" as text)
set theFiles to paragraphs of (do shell script "/usr/bin/find " & quoted form of POSIX path of SourceFolder & " -type f ! -name '.*'")
set {TID, text item delimiters} to {text item delimiters, "/"}
repeat with oneFile in theFiles
tell text items of oneFile to set {fDir, fName} to {items 1 thru -2 as text, last item}
set newFileName to text ((offset of space in fName) + 1) thru -1 of fName
do shell script "/bin/mv " & quoted form of POSIX path of oneFile & space & quoted form of (fDir & "/" & newFileName)
end repeat
set text item delimiters to TID