0
votes

i need a simple generic script [which works on folder opened in finder] that will extract all files from folders while keeping folders alive.

Ie. i have 10 folders and each has 1 file inside. After running script id like to have in same place 10 files and 10 empty folders.

I had some tries with applescript but somehow failed :(

2

2 Answers

0
votes

Try:

set mainFolder to (choose folder)
tell application "Finder"
    set theFiles to files of (entire contents of mainFolder)
    move theFiles to mainFolder
end tell
0
votes

You could also use mv or find:

cd ~/Folder; mv */* .
cd ~/Folder; find . -type f -exec mv {} . \;