Error in Applescript to create named subfolders
Hello,
i'm trying to make a script that creates subfolders for every subfolder of the location you choose, with modified names.
Basically:
- I have Folder/subfolder1, Folder/subfolder2,...
- The script should create Folder/subfolder1/2020_subfolder1, Folder/subfolder2/2020_subfolder2 and so on and so forth
The current error:
"Finder got an error: Can’t get path of folder "test" of folder "Desktop" of folder "johndoe" of folder "Users" of startup disk." - happens on
set myFolderlocation to path of aFolder
Here's my current full code from script editor:
--on run
set theFolder to (choose folder with prompt "Select the folder")
doSomethingWith(theFolder)
--end run
on doSomethingWith(aFolder)
tell application "Finder"
set subFolders to every folder of aFolder
repeat with eachFolder in subFolders
set myFolderlocation to path of aFolder
my doSomethingWith(eachFolder)
end repeat
end tell
--create the name "2020_NameofParentfolder"; this could be simplified
set myParentFolderName to name of aFolder
set mywhataname to ("2020_" & myParentFolderName) as text
--creates the subfolder, with the adapted name i've set before
make new folder at myFolderlocation with properties {name:mywhataname}
end doSomethingWith
Note: I took part of the code from "Iterating through folders" because i don't know applescript too well. https://discussions.apple.com/thread/2716678
I appreciate any help, already spent two or three hours researching but even that's hard with my very low konwledge of applescript.