04-29-2008
Batch changing file extensions
We are moving from an OpenVMS server to a Unix server and I have a problem with ftp'ing files.
When I ftp the VMS server from the Unix server, I need to "mget" some files, for example "mget test_file*.txt;". The semicolon is necessary because OpenVMS has multiple versions of the file (eg test_file.txt;1, test_file.txt;2, etc).
When I do this i end up with the file "test_file.txt;2". I then need to convert this to remove the semicolon.
I have tried various methods and have found one that works :
for file in *.txt*; do
noext="${file%.*}"
mv "$file" "${noext#*.}.txt"
done
However, I have problems with this :
1. it renames ALL .txt files even if they have no ";" and version number.
2. it will only do one file extension at a time.
3. it is inefficient
What I want is to say "for all files with a semicolon in the file extension, rename the file to everything to the left of the semicolon".
Better yet, "give me all files matching *.txt; from theVMS server, and create them on the Unix server without the ;"
Any suggestions would be appreciated.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello people, I was wondering if anyone could help me?
I want to produce a shell script that changes the filename extension on all matching file.
E.G. change all files called ‘something.rtf' to ‘something.doc' by giving the command:
Changex rtf doc
*where ‘Changex' is the name of... (2 Replies)
Discussion started by: thurrock
2 Replies
2. Shell Programming and Scripting
Hi,
I have files with names like file1.txt.txt.txt.txt and file2.txt.txt.txt.txt.txt............ (random infinite number of .txt exist).
how to truncate (mv) their names to ones with single .txt extension like file1.txt and file1.txt ? In other words, how to extract the filename upto first... (12 Replies)
Discussion started by: prvnrk
12 Replies
3. UNIX for Dummies Questions & Answers
Hi all -
I'm trying to rename a large number of files all at once and need some help figuring out the command line syntax to do it. I've already done quite a bit of research with the rename and mv commands, but so far haven't found a solution that seems to work for me. So:
The files exist... (10 Replies)
Discussion started by: dave920
10 Replies
4. UNIX for Dummies Questions & Answers
I copied some files to another folder, and I want to change them from .doc extensions to .txt extensions. I tried using the cp and mv commands, but it didn't work. Is it possible to change file extensions with these commands, and if so how do I do it? I tried using the * wildcard (say cp *.doc... (1 Reply)
Discussion started by: Straitsfan
1 Replies
5. Shell Programming and Scripting
Hi All,
Is there a way to list all file extensions in a directory and its recursive dirs?
Thanks (5 Replies)
Discussion started by: ganga.dharan
5 Replies
6. UNIX for Dummies Questions & Answers
Hi
How can i find the unique list of file extensions in a folder/subfolders
e.g.
MAIN/
a.txt
b.txt
a.clas
a.java
b.class
a.txt.112
c.12.ram.jar
i just need to get the below out irrespective of file being present in folder or subfolders
txt
clas
java (5 Replies)
Discussion started by: reldb
5 Replies
7. Shell Programming and Scripting
I am trying to store file with certain file extensions to list but having some problems.
Here is a part of the code
set fryLst = ""
set fxtLst = ""
foreach f ($AfullNameLst)
set fname = $f:r
set fext = $f:e
if ("$fext" == ".ry") set fryLst = "$fryLst $f"
if ("$fext" == ".xt")... (2 Replies)
Discussion started by: kristinu
2 Replies
8. Shell Programming and Scripting
I'm in csh and have a list of file names, example
set Lst = "file1.ry file2.ry file3.ry file4.ry"
I want to check if all the extensions are ry. Is they are, I want to do something. (1 Reply)
Discussion started by: kristinu
1 Replies
9. Shell Programming and Scripting
Hi Guys,
I have files named myfileaa,myfileab,myfileac,myfilesad.... till myfileav.
Now i needs to rename all these files to myfileaa.txt ,myfileab.txt,myfileac.txt.
Please help me how to do the same.
Thanks in advance..!!! (4 Replies)
Discussion started by: jaituteja
4 Replies
10. Shell Programming and Scripting
Hello Unix board community,
I have to program a shell script, but I am a complete noob so I hope I get some help here. The assignment is as follows:
The program removes all comments regardless of formatting or language from files with specific file name extensions (php, css, js, ...).... (3 Replies)
Discussion started by: TheZeusMan
3 Replies
LEARN ABOUT DEBIAN
debbugsconfig
DEBBUGSCONFIG(8) System Manager's Manual DEBBUGSCONFIG(8)
NAME
debbugsconfig - copy basic debbugs configuration files from templates
SYNOPSIS
debbugsconfig
DESCRIPTION
debbugsconfig will copy basic debbugs configuration files from templates if the files do not already exist, and will also create BTS user
documentation in HTML and text. It should be run on installation and whenever /etc/debbugs/config or /etc/debbugs/text are changed.
FILES
debbugsconfig creates the following template configuration files in $gConfigDir (/etc/debbugs by default):
config General debbugs configuration file.
text Longer messages output by debbugs.
Maintainers
Index of maintainers for each package. This will typically be automatically generated.
Maintainers.override
Manual overrides for the maintainer index.
pseudo-packages.description
Descriptions of any entries in the system's maintainer index that do not correspond to "real" packages. For example, the
Debian Project uses pseudo-packages for bugs against facilities such as the Debian web site, the mailing list archives, and
the bug tracking system itself.
sources
Index of source packages corresponding to each package. This may be used when several packages are produced from a single
source, in which case the bug tracking system will group them together with links in the web front-end.
debbugsconfig creates the following template state files in $gSpoolDir (/var/lib/debbugs/spool by default):
nextnumber
The file which records the tracking number that will be assigned to the next incoming bug report.
index.archive.realtime
Real-time index of archived bugs. Created empty.
index.db.realtime
Real-time index of non-archived bugs. Created empty.
debbugsconfig creates the following documents in $gWebDir (/var/lib/debbugs/www by default):
index.html
Main contents page.
Access.html, bug-log-access.txt
Description of how to access bug reports.
Reporting.html, bug-reporting.txt
Advice on reporting bugs.
server-control.html, bug-maint-mailcontrol.txt
Introduction to the bug control and manipulation mail server.
server-refcard.html, bug-mailserver-refcard.txt
Mail servers' reference card.
server-request.html, bug-log-mailserver.txt
Introduction to the bug system request server.
AUTHORS
debbugsconfig was originally written by Darren Benham and later rewritten by Josip Rodin. Colin Watson wrote this man page.
DEBBUGSCONFIG(8)