| Author |
how to copy a file to a different location with a part of the file name as the filename
|
rahulJ james
Ranch Hand
Joined: Oct 03, 2008
Posts: 123
|
|
I have set of files residing in my hone directory in different naming conventions as shown below,
ap_aearo_prod.20091104044210.Z.20091106.212217
ap_boise_prod.20091029064716_sorted.Z.20091106.212201
ap_boise_prod.20091029064716.Z.20091106.212158
arms_820i_prod.000003ywS.Z.20091109.064508
I wanted to copy these files to a different location with the filename being only till the "Z" i.e.; this file ap_aearo_prod.20091104044210.Z.20091106.212217 has to be copied as ap_aearo_prod.20091104044210.Z, have to truncate the part after the Z.
I have set of files under this directory. This set of files can be identified by the combination of ap_*_prod*20091106* as I need only these files from this datestamp, I have unwanted files with the same datestamp as well.
Can anyone advise
|
 |
Himanshu Rawat
Ranch Hand
Joined: Nov 27, 2005
Posts: 141
|
|
I tried below code on your mentioned files. Give it a try.
PS : Script was in same directory where files are. Customise it
|
rawat
SCJP 1.4
|
 |
rahulJ james
Ranch Hand
Joined: Oct 03, 2008
Posts: 123
|
|
|
Sorry I forgot to mention that I need the script in UNIX. I am sorry for that
|
 |
Himanshu Rawat
Ranch Hand
Joined: Nov 27, 2005
Posts: 141
|
|
|
It's perl script and ran it on linux/unix
|
 |
rahulJ james
Ranch Hand
Joined: Oct 03, 2008
Posts: 123
|
|
|
when you say in your code as <*>, I beleive it will pick all the files under that directory but I want only the files matching as I have explained above
|
 |
Himanshu Rawat
Ranch Hand
Joined: Nov 27, 2005
Posts: 141
|
|
this to
This will take only those files starting with ap_
Hope this helps now
|
 |
Stefan Wagner
Ranch Hand
Joined: Jun 02, 2003
Posts: 1923
|
|
create a local script
chmod a+x adhoc.sh, and
|
http://home.arcor.de/hirnstrom/bewerbung
|
 |
rahulJ james
Ranch Hand
Joined: Oct 03, 2008
Posts: 123
|
|
|
It worked. Thanks
|
 |
 |
I agree. Here's the link: jrebel
|
|
subject: how to copy a file to a different location with a part of the file name as the filename
|
|
|