Skip to content

Instantly share code, notes, and snippets.

@ManWithBear
Created September 4, 2019 08:32
Show Gist options
  • Save ManWithBear/280285dd7d3d92758ccd016c3f5e3fd9 to your computer and use it in GitHub Desktop.
Save ManWithBear/280285dd7d3d92758ccd016c3f5e3fd9 to your computer and use it in GitHub Desktop.
Recursively move files from subfolders to current folder
Transforms:
./Notification/Black@2x.png
./Notification/Black.png
./Sign out/Black.png
./Sign out/Black@2x.png
To:
.Notification_Black@2x.png
.Notification_Black.png
.Sign out_Black.png
.Sign out_Black@2x.png
To test it out:
find . -type f -exec bash -c 'file=${1#./}; echo mv "$file" "${file//\//_}"' _ '{}' \;
To perform:
find . -type f -exec bash -c 'file=${1#./}; mv "$file" "${file//\//_}"' _ '{}' \;
from:
https://unix.stackexchange.com/a/178056
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment