Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FILE_PATH="/my_files/"
- for file in "$FILE_PATH"/*.txt; do
- tmp=${file#*-}; head=${file%-"$tmp"}
- mid=${tmp%-*}; tail=${tmp#"$mid"-}
- base="${head,,}-${tail,,}"
- dir=${base%.txt}
- mkdir -p "$dir"
- mv "$file" "$dir/$base"
- done
- |-- ./
- | |-- xxxx-aaasw1
- | |--xxxx-test_file-aaasw1.txt
- | |-- xxxx-bswb2u
- |--xxxx-test_file-bswb2u.txt.
- |-- ./
- | |-- xxxx-v3u
- | |-- xxxx-test_file-caa-v3u.txt
- | |-- xxxx-
- |-- xxxx-test_file-caa-v3-.txt.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement