Move txt file to with current date appended to filename


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Move txt file to with current date appended to filename
# 1  
Old 12-07-2011
Move txt file to with current date appended to filename

I have multiple txt files which begin with the word "orders" in folder C:\source. I need to move the files to folder C:\dest and rename them to "process_<date>_<count>"

So for example , if there are 3 files ordersa.txt , ordersb.txt and ordersc.txt in C:\source , after running the script I want these files to be in C:\dest with filenames process_12072011_01.txt , process_12072011_02.txt , process_12072011_03.txt

I know its a simple requirement but its munumental for a newbie like me.Smilie
# 2  
Old 12-07-2011
Those "C:\" names don't look like UNIX directories. What's your OS?
# 3  
Old 12-08-2011
using cygwin for windows

IM using Cygwin for Windows to test my scripts ,since I do not have a unix environment at the moment . You can disregard the C:\ , assume the folders are \source and \dest as sub-folders in the same root folder.

Thanks,
# 4  
Old 12-08-2011
You can't disregard the difference of running in Cygwin. It's still subject to all Windows limitations, bugs, and idiosyncrasies. It's not UNIX, just a UNIX porting tool.

You should always explain what your OS is from the first anyway, UNIX or not.

Where does the date come from? The current time, or the file's modification time, or what?
# 5  
Old 12-08-2011
tks

process_12072011_01.txt

12072011 - Date MMDDYYY format
01 - running number ,starting from 01, 02 etc.

I understand cygwin would have the limitations for windows .
# 6  
Old 12-08-2011
Why dont you use a live CD like knoppix and keep a small partition(or USB key...) for you linux files stuff you need read/write ?
# 7  
Old 12-08-2011
isnt there a simple script that i could write for this that i can run in cygwin?
its just a one off requirement to move files and rename them . I really do not want to get into knopix etc. since i dont understand it Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to change existing date to current date in a filename?

Suppose i have a list of files in a directory as mentioned below 1. Shankar_04152019_ny.txt 2. Gopi_shan_03122019_mi.txt 3. Siva_mourya_02242019_nd.txt .. . . . . 1000 . Jiva_surya_02282019_nd.txt query : At one shot i want to modify the above all filenames present in one path with... (4 Replies)
Discussion started by: Shankar455
4 Replies

2. Shell Programming and Scripting

Find file that matches today's date in filename and move to /tmp in bash

I'm having problems with my bash script. I would like to find a file matching today's date in the filename, i.e. my_file_20120902.txt and then move it to a different directory, i.e. /tmp. Thanks. (1 Reply)
Discussion started by: jamesi
1 Replies

3. UNIX for Dummies Questions & Answers

Select text between current date and output to new txt file

Hi guys, brand new to this thread and very very new to UNIX...so go easy please! Anyway I have a file that looks like this: >>-------------------------------------------------------------------------- Date/Time/Eng. : 2012-06-22 / 00:26 / DS Reported problem : (SD) ... (5 Replies)
Discussion started by: martin0852
5 Replies

4. Shell Programming and Scripting

Move txt file to with current date appended to filename

I have multiple txt files which begin with the word "orders" in folder C:\source. I need to move the files to folder C:\dest and rename them to "process_<date>_<count>" So for example , if there are 3 files ordersa.txt , ordersb.txt and ordersc.txt in C:\source , after running the script I want... (1 Reply)
Discussion started by: johannd
1 Replies

5. Shell Programming and Scripting

how to append current date to filename.tgz in perl

i would like to know how to append current date in a filename with .tgz extension. #!/usr/bin/perl my $date = `date + %Y%m%d`; system("sudo mv /tmp/nyucs01_config_backup.tgz /misc/nyucs01_config_backup_$date.tgz"); im getting this error message: sh: line 1: .tgz: command not found (7 Replies)
Discussion started by: linuxgeek
7 Replies

6. Shell Programming and Scripting

[PERL] Cannot stat or move filename - £££F3AERO££.txt

Scenario: Users drop files into a directory which is regularly polled by my PERL process. On detecting a file my process will move it from the poll dir to a working directory. A user created a file with a £ symbol in the filename and my process now fails. e.g £££F3AERO££.txt ... (1 Reply)
Discussion started by: thefal9
1 Replies

7. UNIX for Dummies Questions & Answers

shell scripts - create a filename with the date appended

I am looking to do something where if I created a file named backup,or whatever it would print a name like “backup_Apr_11_2011”. Thanks citizencro (1 Reply)
Discussion started by: citizencro
1 Replies

8. 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

9. Shell Programming and Scripting

how to create file.txt and add current date in file content

Hey guy, how to make bash script to create foo.txt file and add current date into file content and that file always append. example: today the script run and add today date into content foo.txt and tomorrow the script will run and add tomorrow date in content foo.txt without remove today... (3 Replies)
Discussion started by: chenboly
3 Replies

10. UNIX for Dummies Questions & Answers

Append current date to filename

In C Shell programming I haven't successfully been able to append the date in the format mmddyyyy to a filename. I've tried the following: I can print out the date in the correct format: date +%x | sed ‘s/\///g I can create a variable with the filename: set newfile=changedfiles I can... (3 Replies)
Discussion started by: gigigi
3 Replies
Login or Register to Ask a Question