bje
asked on
How to add a value to a file name
How do you add a value to a existing file name. Have a FTP process that receives back a trackingID during the process and when the file is archived needs to be added to the file name before the extension.
For example,
outbound_33333_20130515.xm l need to add a value,
outbound_33333_20130515_H2 3344232.xm l
The added value is stored in a string, called trackingID.
Thank you for the help
Brian
For example,
outbound_33333_20130515.xm
outbound_33333_20130515_H2
The added value is stored in a string, called trackingID.
Thank you for the help
Brian
ASKER
My apology , I am sending files via FTP and trying to change the file name so the tracking id is in the file name before the .xml when the file is move to a archive directory.
the command i am using is
mv $file ${archive_dir}/$file_${Tra ckingID}
Which gives me, outbound_20130517.xml_H233 44232
would like to have
outbound_20130517_H2334423 2.xml
Thanks,
Brian
the command i am using is
mv $file ${archive_dir}/$file_${Tra
Which gives me, outbound_20130517.xml_H233
would like to have
outbound_20130517_H2334423
Thanks,
Brian
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you. this worked.
I am working on another script which uses a "cntr" to keep track of the files and moves them to a archive.
I used this command and not sure what I have wrong with my syntax.
current:
mv ${file_sent[cntr]} ${archive_dir}/${file_sent [cntr]}.${ TrackingID }
tried:
mv ${file_sent[cntr]} ${archive_dir}/${file_sent [cntr]}/./ _${Trackin gID}.}
Thank you for the help
I am working on another script which uses a "cntr" to keep track of the files and moves them to a archive.
I used this command and not sure what I have wrong with my syntax.
current:
mv ${file_sent[cntr]} ${archive_dir}/${file_sent
tried:
mv ${file_sent[cntr]} ${archive_dir}/${file_sent
Thank you for the help
ASKER
Hello,
The solution works. I have a question on how you would insert a field when the file has a period inbetween the values.
example
apa.out.name.txt
would like to but a date/time stamp after name
apa.out.name.2013091314001 0.txt
my file name comes out app.20130913140010.out.nam e.txt
Thanks,
BJE
The solution works. I have a question on how you would insert a field when the file has a period inbetween the values.
example
apa.out.name.txt
would like to but a date/time stamp after name
apa.out.name.2013091314001
my file name comes out app.20130913140010.out.nam
Thanks,
BJE
file=apa.out.name.txt
trackingID=20130913140010
echo ${file%.*}.$trackingID.${f ile##*.}
trackingID=20130913140010
echo ${file%.*}.$trackingID.${f
ASKER
Thanks
trackingID=outbound_33333_
echo ${trackingID/./_H23344232.