Rename a file if I don't know its exact original name?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Rename a file if I don't know its exact original name?
# 8  
Old 03-06-2006
vgersh99, it seems to me that with nmap you are assigning values to variables ($1 and $3 in your example) and using those variables to re-format the string.

However, I did just realize that I also have to rename the _IN.TXT to lowercase. Does this mean the 2nd option is better?

Thanks again
# 9  
Old 03-06-2006
you can try:
Code:
ftp host
    nmap $1_$2_$3 $1_$3
    case
    mget SCA*.TXT

to map all CAPs to low case....
You can play with either 'nmap' and/or 'macdef' to get the desired result OR go the 'post processing' route, but it might interesting to figure out how to do it natively within ftp.
# 10  
Old 03-07-2006
Althought this is more complicated ,u can try:

for EXT_FILE in $(ftp -n ${HOST} < files.ftp | grep -vE "^Passive|^total" |grep -v active|awk -F\SCA '{print $2}')
do
echo ${EXT_FILE} >>files_ext-list.tmp
done

cat files_ext-list.tmp|while read EXT_FILE
do
EXT_FILE2="$(echo ${EXT_FILE}|awk -F\_ '{print $1}')_in.txt"
echo "define(EXT_FILE,${EXT_FILE}) define(EXT_FILE2,${EXT_FILE2})" > out.macros
cat out.macros download_files.ftp | m4 -B64556 > temp.ftp
ftp -n ${HOST} < temp.ftp
done


Where:


cat files.ftp

user username password
passive
dir
bye


cat download_files.ftp

user username password
passive
get "SCA""EXT_FILE" "SCA""EXT_FILE2"
bye



Cheers
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Recover the original file once removed

Hi All, Is there is any machanisim, once delete the file can we restore it. Thanks (8 Replies)
Discussion started by: bmk123
8 Replies

2. Shell Programming and Scripting

Find the original file size of encrypted file

Hi, I am trying to find out the original file size of an encrypted file in SunOS. The file was decrypted with gpg command. I want to know the size of the orginal file without decrypting it. I am using the below command, but it is not working for big files(more than 1 GB). gpg --passphrase... (4 Replies)
Discussion started by: vsachan
4 Replies

3. Shell Programming and Scripting

Merge different files into the original file

Hello Below is my requirement I have 3 files A1.txt , A2.txt and A3.txt . A2 is dynamically generating file I want the merge of A1,A2 and A3 in A2.txt Could you please help? (3 Replies)
Discussion started by: Pratik4891
3 Replies

4. Shell Programming and Scripting

echo exact xml tag from an exact file

Im stumped on this one. Id like to echo into a .txt file all names for an xml feed in a huge folder. Can that be done?? Id need to echo <name>This name</name> in client.xml files. $path="/mnt/windows/path" echo 'recording names' cd "$path" for names in $path than Im stuck on... (2 Replies)
Discussion started by: graphicsman
2 Replies

5. Shell Programming and Scripting

QUESTION1: grep only exact string. QUESTION2: find and replace only exact value with sed

QUESTION1: How do you grep only an exact string. I am using Solaris10 and do not have any GNU products installed. Contents of car.txt CAR1_KEY0 CAR1_KEY1 CAR2_KEY0 CAR2_KEY1 CAR1_KEY10 CURRENT COMMAND LINE: WHERE VARIABLE CAR_NUMBER=1 AND KEY_NUMBER=1 grep... (1 Reply)
Discussion started by: thibodc
1 Replies

6. UNIX for Dummies Questions & Answers

command to change original file

I have a script where I have the command sed "s/$search_string/$replace_string/g" $backup However I want a command to correct the original file $backup as well as creating another file with the changes which I have in my script already. In other words, I want to touch the orginal file also... (1 Reply)
Discussion started by: alis
1 Replies

7. UNIX for Dummies Questions & Answers

CSV file:Find duplicates, save original and duplicate records in a new file

Hi Unix gurus, Maybe it is too much to ask for but please take a moment and help me out. A very humble request to you gurus. I'm new to Unix and I have started learning Unix. I have this project which is way to advanced for me. File format: CSV file File has four columns with no header... (8 Replies)
Discussion started by: arvindosu
8 Replies

8. Shell Programming and Scripting

mv command to rename multiple files that retain some portion of the original file nam

Well the title is not too good, so I will explain. I need to move (rename) files using a simple AIX script. ???file1.txt ???file2.txt ???file1a.txt ???file2a.txt to be: ???renamedfile1'date'.txt ???renamedfile2'date'.txt ???renamedfile1a'date'.txt ???renamedfile2a'date'.txt ... (4 Replies)
Discussion started by: grimace15
4 Replies
Login or Register to Ask a Question