Recently, I was handed a project with pre-built ANT scripts that zip folders up into individual directories. The zip files in each folder needed to be uploaded to an FTP site without the folder so having to navigate into each was a bit annoying and time consuming for 40 files.

If you find yourself in need of merge or flatten a folder/directory, use this snippet to flatten everything into a single directory. If a file exists with the same name, you’ll be prompted to overwrite or leave in the existing folder.

find $PWD -mindepth 2 -type f -exec mv -i '{}' $PWD/ ';'

In my case, there was an extra file generated within each folder that was not used and I didn’t want to be prompted 40 times to overwrite so changing the -i to -n will force files to be overwritten. I’d recommend using caution with this and only use it when you know the duplicate files don’t matter.

find $PWD -mindepth 2 -type f -exec mv -n '{}' $PWD/ ';'

 

How to Fix ‘Converter Failed to Save File’ with Excel 2016 How to Prevent Raspberry Pi Zero from Blanking or Sleeping
View Comments
There are currently no comments.