Sponsored Content
Top Forums UNIX for Dummies Questions & Answers move files according to dated filename Post 302519157 by rdcwayx on Tuesday 3rd of May 2011 07:02:22 AM
Old 05-03-2011
Code:
ls [12]*_*.pdf |while read file
do
  year=${file:0:4}
  month=${file:4:2}
  [[ -d $year/$month ]] || mkdir -p $year/$month 
  mv "$file" "$year/$month/$file"
done

 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to move files into different folders based on filename

I need to move a bunch of files into folders that have the same name. I wanted to either do this with some filter command or some type of batch file that I could save that would already include all of the mv commands since I will have to do this process often. Whatever method you think is easier. ... (7 Replies)
Discussion started by: italia5
7 Replies

2. Shell Programming and Scripting

move filenames with to another filename without the last character ~

Hi, I need to move filenames with the following format below into filenames without the ~ like sample below. I hope you can help me create a simple unix script that will do this. Thanks in advance! move filename from: AIRS20081225-235641.BSP~ AIRS20081225-235648.BSP~ AIRS20081225-235640.BSP~... (3 Replies)
Discussion started by: ayhanne
3 Replies

3. UNIX for Dummies Questions & Answers

want to move files in a dir into different directories based on the filename

I want to move the files in a dir to different dirs based on their file names. Ex: i have 4 different files with name - CTS_NONE_10476031_MRL_PFT20081215a.txt CTS_NONE_10633009_MRL_PFT20091020a.txt CTS_NONE_10345673_MRL_PFT20081215a.txt CTS_NONE_10872456_MRL_PFT20091020a.txt and the 1st... (2 Replies)
Discussion started by: Sriranga
2 Replies

4. Shell Programming and Scripting

want to move files in a dir into different directories based on the filename

I want to move the files in a dir to different dirs based on their file names. Ex: i have 4 different files with name - CTS_NONE_10476031_MRL_PFT20081215a.txt CTS_NONE_10633009_MRL_PFT20091020a.txt CTS_NONE_10345673_MRL_PFT20081215a.txt CTS_NONE_10872456_MRL_PFT20091020a.txt and the 1st... (4 Replies)
Discussion started by: Sriranga
4 Replies

5. Shell Programming and Scripting

Move file based on filename

Hi All I need a script to manipulate files based on a filename: example filename: 66600_042706.pdf the script will create a directory 66000 only if this directory is not existing. If that directory is existing it will just move the file to 66000/666000_042706.pdf in addition, i want to... (4 Replies)
Discussion started by: aemestech
4 Replies

6. Shell Programming and Scripting

Move files based on date in filename

I know this gets covered quite a bit in the forum and I think there is enough there for me to figure out how to do what I am trying to do, I just don't think I would do it very efficiently so I am going to ask the question... I have database log files with date and time stamps in the file like ... (7 Replies)
Discussion started by: slatoms
7 Replies

7. Shell Programming and Scripting

Move all files from source to destination directory based on the filename

Move all files starting with a specific name to different directory. This shell script program should have three parameters File Name Source Directory Destination Directory User should be able to enter ‘AB_CD*' in file name parameter. In this case all the files starting with AB_CD will... (1 Reply)
Discussion started by: chetancrsp18
1 Replies

8. Windows & DOS: Issues & Discussions

Move all files with pattern in filename

Well. I would love to have a way to: 1.) search a folder, lets say: X:\Files for any file that contains a "Conflict" in its filename (only!) (recursively so it searches the whole contents of the folder) 2.) Move all files to another Folder. All this under DOS. Any help... (6 Replies)
Discussion started by: pasc
6 Replies

9. Shell Programming and Scripting

Deleting dated log files whihc are older than an year

Hi. There is a process which creates log files in the below naming format processname.20140425.log processname1.20140425.log And in this path along with these logs there are other files which have the timestamp from 2012 and i want to have a script in place to delete only the above log files... (13 Replies)
Discussion started by: nanz143
13 Replies
CAL(1)							    BSD General Commands Manual 						    CAL(1)

NAME
cal -- displays a calendar SYNOPSIS
cal [-smjy13] [[month] year] DESCRIPTION
Cal displays a simple calendar. If arguments are not specified, the current month is displayed. The options are as follows: -1 Display single month output. (This is the default.) -3 Display prev/current/next month output. -s Display Sunday as the first day of the week. (This is the default.) -m Display Monday as the first day of the week. -j Display Julian dates (days one-based, numbered from January 1). -y Display a calendar for the current year. A single parameter specifies the year (1 - 9999) to be displayed; note the year must be fully specified: ``cal 89'' will not display a calen- dar for 1989. Two parameters denote the month (1 - 12) and year. If no parameters are specified, the current month's calendar is displayed. A year starts on Jan 1. The Gregorian Reformation is assumed to have occurred in 1752 on the 3rd of September. By this time, most countries had recognized the ref- ormation (although a few did not recognize it until the early 1900's.) Ten days following that date were eliminated by the reformation, so the calendar for that month is a bit unusual. HISTORY
A cal command appeared in Version 6 AT&T UNIX. OTHER VERSIONS
Several much more elaborate versions of this program exist, with support for colors, holidays, birthdays, reminders and appointments, etc. For example, try the cal from http://home.sprynet.com/~cbagwell/projects.html or GNU gcal. BSD
June 6, 1993 BSD
All times are GMT -4. The time now is 01:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy