|
|
Flatten a folder's structure via AppleScript
I've actually never had to do this, but I was curious to see what shell equivalent would be. Make sure you change into the top level of the directory hierarchy you want to flatten!
These commands just print out what they would do. To make these actually work remove the word echo from the commands.
find . -not -type d -print0 | xargs -0J % echo mv -f % . find . -type d -depth 1 -print0 | xargs -0 echo rm -rfIf you're using zsh as your shell, depending on your options, this may work for reasonably sized trees. echo mv -f **/*(.) . echo rm -rf *(/)
Flatten a folder's structure via AppleScript
That's what I was thinking. Better still, use
mv --backup in the first command. If a new file is copied with the same name as an existing file, the existing file will have a number appended to its name.
Flatten a folder's structure via AppleScript
Flatten a folder's structure via AppleScript
I tried the shell script thing extensively but it does not deal well with special characters in folder/file names. Parentheses, punctuation. slashes, etc all freak out a shell script [ at least my shell scripts]
Flatten a folder's structure via AppleScript
Hint 1: Put all variables containing filenames in "" when using them to reference a file/directory (resolves all practical issues)
Flatten a folder's structure via AppleScript
Stumbled across this thread while researching a script for reorganizing some really unwieldy folder structures and 30,000 files, Thought I'd post back with my results in case it's useful to any one. I decided on a shell script version; it ended up being much faster than the Applescript versions I tried.
My basic goal was to flatten all files to the main folders, but for the larger folders (containing up to 4000 files) I wanted to sort the files into alphabetical subfolders. I decided on running the script as a contextual menu item using OnMyCommand, so all selected folders in the Finder are passed to the script one at a time. So if you're using Applescript or Platypus to set up a droppable app or whatever you'll need to set up the folder handling. Note that I used a Macports-installed version of GNU mv (gmv) for moving files, since the default mv on my Tiger setup doesn't support the "--backup" option. The script moves any duplicates found to a folder named "Duplicate". Also any invisible dot files (like .DS_store) in the main folder should be preserved; any in subfolders will be deleted.
|
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.10 seconds |
|