I am writing a script that will scan through The selected files and folders and
If the file is *.wav or *.flac then It will open it (xld will convert to m4a file)
If the item is a folder it will scan Through its itemsTo do the same thing above.
The script works fine if I only select files, But it does not scan through folders. Can someone please help. Thanks.
tell application "Finder"
set _data to selection
_convertmusic(_data) of me
end tell
on _convertmusic(_allfiles)
tell application "Finder"
repeat with _file in _allfiles
if kind of _file is "folder" then
_convertmusic(every file of _file) of me
else if name extension of _file is "wav" or name extension of _file is "flac" then
open _file
end if
end repeat
end tell
end _convertmusic
property pListaFiles : missing value
set pPathOriginaliPosix to "Macintosh HD:Users:stefano:Desktop:Camera:"
set pListaFiles to {}
scanRecursive(pPathOriginaliPosix)
pListaFiles
on scanRecursive(thePath)
tell application "Finder"
set listaFiles to name of every file in folder thePath
set listaFolder to name of every folder in folder thePath
end tell
repeat with j from 1 to count listaFiles
if (item j of listaFiles) ends with ".mp4" then
copy (thePath & item j of listaFiles) to end of pListaFiles
end if
end repeat
repeat with j from 1 to count listaFolder
set folderPath to (thePath & item j of listaFolder & ":") as string
scanRecursive(folderPath)
end repeat
end scanRecursive
Just change the extension and/or add new items to compare.
You cna also define an array of extension to filters and extract the extension of file an compare the extension if is inside the array.