LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-20-2013, 12:58 AM   #1
Adam.mint
LQ Newbie
 
Registered: Apr 2013
Posts: 4

Rep: Reputation: Disabled
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,
 
Old 04-20-2013, 01:12 AM   #2
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
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.
 
Old 04-20-2013, 01:28 AM   #3
Adam.mint
LQ Newbie
 
Registered: Apr 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
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,
 
Old 04-20-2013, 02:33 AM   #4
Adam.mint
LQ Newbie
 
Registered: Apr 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
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,
 
Old 04-20-2013, 03:26 AM   #5
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Quote:
Originally Posted by Adam.mint View Post
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 \;
 
Old 04-20-2013, 04:04 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
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.
 
Old 04-20-2013, 04:22 AM   #7
mddnix
Member
 
Registered: Mar 2013
Distribution: Redhat, Ubuntu
Posts: 516

Rep: Reputation: 139Reputation: 139
Quote:
Originally Posted by Adam.mint View Post
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

Last edited by mddnix; 04-20-2013 at 04:25 AM.
 
Old 04-20-2013, 04:22 AM   #8
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
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".
 
1 members found this post helpful.
Old 04-20-2013, 05:11 AM   #9
Adam.mint
LQ Newbie
 
Registered: Apr 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
jpollard! thanks mate, your answer is the I was looking for, Solved.


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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to move or copy files present between two dates to another path folder. ankitpandey Linux - General 22 02-06-2012 02:21 AM
[SOLVED] make a folder for each file in a directory then move the file into it genderbender Programming 14 12-02-2010 11:59 AM
[SOLVED] move file and folder date stamps smithy2010 Linux - Newbie 3 05-08-2010 11:52 AM
find and move to folder and file dulahdaglace Linux - Newbie 1 09-15-2009 11:44 PM
Help me...after used mv command all file missing only folder move to new path scoreone1 Linux - General 9 10-21-2008 12:22 AM


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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration