Thread: move files recursively to new folders with the same name as the file?
hi,
how can move files recursively new folders same name file
example
have folder containing 500 files various names same extension .txt
need make 500 new folders same names of files move 500 files folders.
i think can simple parameter expansion , loop, sort of like:
a couple notes...change 'file*.txt' match have. might use '*.txt'. also, i've left echo statement in there testing purposes. show moved, not move. when you're satisfied how it's working, remove word 'echo' , let loose.code:#!/bin/bash file in file*.txt dir="${file%.*}" echo mv "$file" "${dir}/${dir}.txt" done
Forum The Ubuntu Forum Community Ubuntu Official Flavours Support General Help [SOLVED] move files recursively to new folders with the same name as the file?
Ubuntu
Comments
Post a Comment