Sponsored Content
Full Discussion: Renaming file in batch
Top Forums Shell Programming and Scripting Renaming file in batch Post 302929654 by Don Cragun on Wednesday 24th of December 2014 01:32:41 AM
Old 12-24-2014
You can use anbu23's suggestion as a starting point, with some minor changes since the names you want aren't stored in a file and since you don't want the numbers in the new names to start at 00001. If the command ls *-00000.cdr works without giving you an error for an argument list that is too long, try something like:
Code:
startseq=92311
ls *-00000.cdr | awk -v s="$startseq" '{f=$0;sub("00000.cdr",sprintf("%05d.cdr",s++)); print "mv", f, $0}' | sh

otherwise, try something like:
Code:
startseq=92311
ls | grep -F '-00000.cdr' | awk -v s="$startseq" '{f=$0;sub("00000.cdr",sprintf("%05d.cdr",s++)); print "mv", f, $0}' | sh


Last edited by Don Cragun; 12-24-2014 at 04:01 AM.. Reason: Changed ".txt" to ".cdr" to match name changes in post #1 in this thread.
This User Gave Thanks to Don Cragun For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

simple batch renaming...45-*.php to 46-*.php

in Bash i'm trying to rename directories full of files. the file name pretty much stays the same except for the numerical prefix which will be the same for all files. so, i want to rename these... 45-body.php 45-header.php 45-footer.php etc. to... 46-body.php 46-header.php... (2 Replies)
Discussion started by: bcamp1973
2 Replies

2. UNIX for Dummies Questions & Answers

Batch Renaming: Change files' extensions in many sub-directories

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

3. Shell Programming and Scripting

batch renaming ...

hi all, given a path, for example : /<pwd>/artist/album/ what i would like to do is to rename the album directory like that : /<pwd>/artist/artist | album/ and i would like to do the latter for all the "artist" directories and for all the "album" directories that belong to an artist ... (4 Replies)
Discussion started by: OneDreamCloser
4 Replies

4. UNIX for Dummies Questions & Answers

Batch Renaming of Files

Hello all, thanks for your time (and this forum, what an awesome resource for newbs like myself!) Anyways, I've been given the task of importing content from a directory of about...7000 HTML files. They are all named appropriately and broken down by name depending on what book they belong too.... (8 Replies)
Discussion started by: gratefulhokie
8 Replies

5. Shell Programming and Scripting

script for renaming a batch of files

hi i have a folder full of files. some of the names are quite off because the dimensions were the same and i had to put a 'b' after the initial number so that it didnt overwrite. what i want is a script in unix to overwrite the filwe name leaving some of the title intact, e.g. below are some... (3 Replies)
Discussion started by: shabs1985
3 Replies

6. Shell Programming and Scripting

BASH Batch renaming insert additional zero into filename

Hi all, Wondering how this could be accomplished........ a directory contains sequentially numbered files from fw01 to fw999. How would I insert an additional zero so that the directory lists these files in a proper manner? (i.e. all double digit files from fw01 to fw99 would become... (3 Replies)
Discussion started by: putter1900
3 Replies

7. Shell Programming and Scripting

Need help in batch renaming files with bash shell script.

I have some 50+ files in the following format : abcd_vish_running_ZEBRA_20140818.dat_08-14-2014_23:08:23 abcd_vish_running_ZEB-RA_20140818.dat_08-14-2014_23:08:35 abcd_vish_running_ZEB_RA_20140818.dat_08-14-2014_23:08:37 abcd_vish_running_RI-NG_20140818.dat_08-14-2014_23:08:42... (5 Replies)
Discussion started by: SriRamKrish
5 Replies

8. Shell Programming and Scripting

SFTP batch not renaming file with "put"

I have a .ksh script that creates an sftp batch file and runs it through sftp. It works except for one thing. If I try to "put" to a different name, it doesn't use the specified remote name...it still "puts" the original local name. I've tried both of these, and neither work...it will always... (4 Replies)
Discussion started by: dbiggied
4 Replies

9. Shell Programming and Scripting

Script for batch renaming

What is wrong with this script to rename batch of similar files? For example renaming all *.txt files to *.tab . $ for i in seq {01..10}; do touch ${i}.txt; done $ ./rename.sh *.txt txt tab Error: mv: ‘01.txt’ and ‘01.txt’ are the same file. Code is: #!/usr/bin/bash # renames.sh #... (6 Replies)
Discussion started by: yifangt
6 Replies

10. UNIX for Beginners Questions & Answers

Renaming batch by removing substring

I wish to rename all files ending in .txt by removing .tex. Currently I have me@me-Inspiron-518:~$ ls a.tex.txt bin b.tex.txt c.tex.txt Desktop Documents Downloads d.tex.txt Music Pictures Public Templates VideosDesired outcome me@me-Inspiron-518:~$ ls a.txt ... (2 Replies)
Discussion started by: Xubuntu56
2 Replies
GCONFTOOL-2(1)							   User Commands						    GCONFTOOL-2(1)

NAME
gconftool-2 - GNOME configuration tool SYNOPSIS
gconftool-2 [-?] [-?|--help] [--usage] [-s|--set] [-g|--get] [--set-schema] [-u|--unset] [--recursive-unset] [-a|--all-entries] [--all-dirs] [--dump] [--load=STRING] [-R|--recursive-list] [--dir-exists=STRING] [--shutdown] [-p|--ping] [--spawn] [-t|--type int|bool|float|string|list|pair] [-T|--get-type] [--get-list-size] [--get-list-element] [--list-type=int|bool|float|string] [--car-type=int|bool|float|string] [--cdr-type=int|bool|float|string] [--short-desc=DESCRIPTION] [--long-desc=DESCRIPTION] [--owner=OWNER] [--install-schema-file=FILENAME] [--config-source=SOURCE] [--direct] [--makefile-install-rule] [--makefile-uninstall-rule] [--break-key] [--break-directory] [--short-docs] [--long-docs] [--get-schema-name] [--apply-schema] [--unapply-schema] [--get-default-source] [-v|--ver- sion] DESCRIPTION
Each preference in the GConf repository is expressed as a key-value pair. A GConf preference key is an element in the GConf repository that corresponds to an application preference. Preference keys typically have simple values such as strings, integers, or lists of strings and integers. The default key-value pairs are installed on the system, and are known as schemas. gconftool-2 is the command-line interface tool that enables you to set the values of keys, display the values of keys, and install schemas from schema definition files when you install an application. The GConf preference keys are stored and managed by the GConf daemon (gconfd-2). These keys are cached in memory, and saved to disk in XML format when appropriate. OPTIONS
-s, --set Set a key to a value and sync. Use with --type. -g, --get Print the value of a key to standard output. -u, --unset Unset the keys on the command line. --recursive-unset Recursively unset all keys at or below the key/directory names on the command line. -a, --all-entries Print all key/value pairs in a directory. --all-dirs Print all subdirectories in a directory. -R, --recursive-list Print all subdirectories and entries under a dir, recursively. --dir-exists=STRING Return 0 if the directory exists, 2 if it does not. -t, --type=int|bool|float|string|list|pair Specify the type of the value being set, or the type of the value a schema describes. Unique abbreviations are allowed. --list-type=int|bool|float|string Specify the type of the list value being set, or the type of the value a schema describes. Unique abbreviations are allowed. --car-type=int|bool|float|string Specify the type of the car pair value being set, or the type of the value a schema describes. Unique abbreviations are allowed. --cdr-type=int|bool|float|string Specify the type of the cdr pair value being set, or the type of the value a schema describes. Unique abbreviations are allowed. --short-desc=DESCRIPTION Specify a short half-line description to go in a schema. --long-desc=DESCRIPTION Specify a several-line description to go in a schema. --owner=OWNER Specify the owner of a schema. --install-schema-file=FILENAME Specify a schema file to be installed --config-source=SOURCE Specify a configuration source to use rather than the default path --direct Access the config database directly, bypassing server. Requires that gconfd is not running. --set-schema Set a schema and sync. Use with --short-desc, --long-desc, --owner, and --type. --makefile-install-rule Properly installs schema files on the command line into the database. GCONF_CONFIG_SOURCE environment variable should be set to a non-default config source or set to the empty string to use the default. --break-key Torture-test an application by setting and unsetting a bunch of values of different types for keys on the command line. --break-directory Torture-test an application by setting and unsetting a bunch of keys inside the directories on the command line. --short-docs Get the short doc string for a key --long-docs Get the long doc string for a key --get-schema-name Get the name of the schema applied to this key --apply-schema Specify the schema name followed by the key to apply the schema name to --unapply-schema Remove any schema name applied to the given keys --get-default-source Get the name of the default source. --shutdown Shut down gconfd. Don't use this option without good reason. -p, --ping Return 0 if gconfd is running, 2 if not. --spawn Launch the config server (gconfd). (Normally happens automatically when needed.) -v, --version Print version Help options -?, --help Show the help message. EXAMPLES
Display the path to the current desktop wallpaper. gconftool-2 --get /desktop/gnome/background/picture_filename Change the widget font to "Serif 12" gconftool-2 --type string --set /desktop/gnome/interface/font_name "Serif 12" AUTHOR
GConf was written by Havoc Pennington <hp@redhat.com>. SEE ALSO
The GConf web site, http://www.gnome.org/projects/gconf/. gconftool-2 2.2.1 February 2006 GCONFTOOL-2(1)
All times are GMT -4. The time now is 08:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy