LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   move multiple file by similar name or by dates tamp to a folder (https://www.linuxquestions.org/questions/linux-newbie-8/move-multiple-file-by-similar-name-or-by-dates-tamp-to-a-folder-4175458841/)

Adam.mint 04-20-2013 12:58 AM

move multiple file by similar name or by dates tamp to a folder
 
Hi,

Guyz I will appreciate any help regarding the issue, I am googleing the issue alot but have not find what I am looking for.

I have seen someone using a single line command for moving files (either by similar name or By created date)...... and I am searching for that command since past two days, but no luck...

the files are asterisk call recordings: .wav and I want to move them in their respective date folders.

Cheers,

shivaa 04-20-2013 01:12 AM

Wasn't it find cmd, like this:
Code:

~$ find /path/to/source -name '*.wav' -exec mv '{}' /path/to/target \;
See manual of find here for more options.

Adam.mint 04-20-2013 01:28 AM

Thanks for your reply, files are named like this, lets say I want to move all files created on 20130418 to a folder 180413.

IN-ext 1030 <0000000000>--861893114428-20130417-02:30:15-1366180215.1391.wav
IN-ext 1030 <0000000000>--861893178434-20130419-06:05:51-1366365951.2829.wav
IN-ext 1030 <0000000000>--861893191169-20130418-23:48:54-1366343334.128.wav
IN-ext 1030 <0000000000>--861893304401-20130418-06:39:21-1366281561.2397.wav
IN-ext 1030 <0000000000>--861893321631-20130418-06:38:31-1366281511.2389.wav


cheers,

Adam.mint 04-20-2013 02:33 AM

dialer:/recordings/manual # find -mtime +3 -exec mv '{}' /recordings/April/160413 \;

I tried it, it kind of moved some files but it also moved the manual folder in the destination. any suggestions

cheers,

shivaa 04-20-2013 03:26 AM

Quote:

Originally Posted by Adam.mint (Post 4935123)
dialer:/recordings/manual # find -mtime +3 -exec mv '{}' /recordings/April/160413 \;

This is incorrect command. You need to mention /path/to/source after find as,
Code:

~$ find /path/to/source -mtime -3 -exec mv '{}' /recordings/April/160413 \;
But it will move all files/directories modified 3 days ago. So try following:
Code:

~$ find /path/to/source -mtime -3 -name '*.wav' -exec mv '{}' /recordings/April/160413 \;

druuna 04-20-2013 04:04 AM

Just a heads up about using -mtime:

Using -mtime -3 will find _all_ files younger the 3 days, using -mtime +3 finds _all_ files older then 3 days.
This will find files modified 3 days ago: find /path/to/source -daystart -mtime 3 ..........

Also: the -mtime option does not look at the file name, it looks at the modification date. I'm mentioning this because the example in post #3 deals with file names that have dates in them, it is not clear if the modification date is the same.

mddnix 04-20-2013 04:22 AM

Quote:

Originally Posted by Adam.mint (Post 4935105)
Thanks for your reply, files are named like this, lets say I want to move all files created on 20130418 to a folder 180413.

Code:

$ find /source-directory/ -newermt "2013-04-18" -iname "*.wav" -exec mv {} /target-directory/180413/ \;
More: Linux / Unix: Find Files Modified On Specific Date

jpollard 04-20-2013 04:22 AM

one awkward way to handle it with file names:
Code:

mv *--????????????-20130417-*.wav <destintation>
There are several variations - read the bash manpage on "Pattern Matching".

Adam.mint 04-20-2013 05:11 AM

jpollard! thanks mate, your answer is the I was looking for, Solved.


Shiva, mddesai, drunaa, thanks for you help. problem solved.


All times are GMT -5. The time now is 10:55 AM.