Hi everyone,
It’s me (again), and i have a little bit of a hickup.
I’m trying to grab the newest file that get’s added to a certain folder. That in it self isn’t very hard, but the file name is randomized (always having 40 characters), and i’d like to rename it to a human readable name.
for example, it’s now called “84c9bcbea8cf8b0ebd96184e248a262b6f379e83”
And it’s neatly being copied to a folder of my choosing using this script, however, i’d like to change it’s name and extension. But that seems hard to do because it’s name is, as i said earlier, randomized. What would be the best way to aproach this? should I use this do shell script "ls -l"
to grab all file names and find out which one has 40 characters, or should i copy it to a empty temporary folder after which i rename all files (that one) in that folder?
At this point i got this:
on extractNow_()
log "Generating path to Kuvva Folder.."
set pathp1 to (path to desktop as text)
set applescript's text item delimiters to ":"
set pathp2 to (text item 1 thru 3 of pathp1 as text & ":")
set pathp3 to pathp2 & "Library:Application Support:Wallpapers:Data:Wallpaper:"
set pathp4 to (POSIX path of pathp3)
set WallpaperPath to pathp4
set ExtractPathPOSIX to POSIX path of ExtractPath
log "Extraction running"
do shell script "cp -a " & (quoted form of WallpaperPath) & ". \"" & extractPathPOSIX & "Extract\""
tell application "Finder"
set all_files to get items of (extractPath & "Extract:")
repeat with ff in all_files
set applescript's text item delimiters to ""
if (count text items of ff) = "40" then
set ff's name to "Extract"
set ff's file type to "jpg"
end
end repeat
end tell
end extractNow_
If any of you could help, thank you very much for it!
Model: Macbook Pro
AppleScript: Latest (10.9.2)
Browser: Safari 537.74.9
Operating System: Mac OS X (10.8)