Last active
January 9, 2020 20:22
-
-
Save schluppeck/30164a20b64fba8951b2c7847cf4b450 to your computer and use it in GitHub Desktop.
using a bash look and awk to rename some badly formed file names
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# dealing with OneDrive filesep issues... | |
# | |
# ds 2020-06-09, coffee break unix hacking. | |
# shell loop for moving files with windows sep \ into folders with filesep / | |
# for example: files called Carblblblabl\ACTUAL_FILE.jpg | |
# should go into folder Carblblblabl/ACTUAL_FILE.jpg | |
# idea. use AWK with field sep \ to split into two strings. | |
# then paste them together with / and use in unix/mv | |
for f in `ls -1 Car*.{jpg,mat}` ; do | |
g=$(echo $f | awk -F '\' '{print $1 "/" $2}') | |
echo "moving ${f} to ${g}" | |
mv ${f} ${g} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment