Re: Bulk moving of files
- From: Robert Latest <boblatest@xxxxxxxxx>
- Date: 23 Mar 2010 18:47:07 GMT
Owen wrote:
I just polluted a directory with 100 odd files, they were meant to go
into a sub directory. All files have a date so that ls -l|grep
'2010-03-23' list the files that need moving.
What one liner can I use to move them all into the sub directory in
one operation?
Hello Owen,
you've already got some good answers on this one, but here's something I
find myself doing quite often: an ls | sed | sh pipe. Recently I had to
convert a bunch of files that had dates of the form DD.MM.YYYY in their
(otherwise quite random) names to easily sortable names like
file_YYYY-MM-DD.txt.
This is what I did: ls | sed -nr
's/.*([0-9]{2})\.([0-9]{2})\.([0-9]{4}).*/mv -i "\0"
file_\3-\2-\1.txt/p' | sh
(typed from memory, there might be syntax issues).
I also like to generate shell scripts using find's -printf directive.
Actually, find, sed and sh make an extremely powerful batch file
operation team.
robert
.
- References:
- Bulk moving of files
- From: Owen
- Bulk moving of files
- Prev by Date: ╰☆╮╰☆╮╰☆╮ 2010 Cheap *** True Relig Jeans at website: http://www.fjrjtrade.com <***>
- Next by Date: Re: Want to insert some stuff as a new line after the line matching regexp.
- Previous by thread: [OT] Re: Bulk moving of files
- Next by thread: ╰☆╮╰☆╮╰☆╮ 2010 Cheap *** True Relig Jeans at website: http://www.fjrjtrade.com <***>
- Index(es):