Sponsored Content
Top Forums Shell Programming and Scripting Renaming of files with different extensions on the same path to .found with the help of loop Post 302418642 by pravin27 on Wednesday 5th of May 2010 02:39:19 AM
Old 05-05-2010
Hi,

I have just print the mv command, u can modify according your requirement.

Code:
#!/bin/sh

ls | while read  first_file
do
ext=`echo $first_file | awk -F'.' '{print $2}'`
bsnm=`basename $first_file ".$ext"`
echo "mv $first_file $bsnm.found"
done

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

cc path problem - no acceptable path found

Hello everyone, I'm a unix noob. I have a powerbook running mac os x 10.4 and for one of my classes I need to install the latest version of php (5.0.5). I'm following the instructions at http://developer.apple.com/internet/opensource/php.html to install but I've run into a problem. The... (2 Replies)
Discussion started by: kendokendokendo
2 Replies

2. UNIX for Dummies Questions & Answers

setEnv.sh is found in which directory(path)

Hi, I am new to Unix.I want to set the path and classpath setting for JDK1.4,Weblogic 9.2 and Oracle 9? So i need to set those settings in setEnv.sh file. But i am unable to find that file in my unix environment? Pls. do tell me where this setEnv.sh is stored? In which directory or path?... (8 Replies)
Discussion started by: sachin.tendulka
8 Replies

3. Shell Programming and Scripting

find command in while loop - how to get control when no files found?

I have the following statement in script: find ${LANDING_FILE_DIR}${BTIME_FILENAME_PATTERN2} -print | while read file; do ... done When there are no files located by the find comand it returns: "find: bad status-- /home/rnitcher/test/....." to the command line How do I get control in... (3 Replies)
Discussion started by: mavsman
3 Replies

4. 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

5. Shell Programming and Scripting

Loop through found files

Hi I am trying to write a script which will loop through all files that end in ".txt" and ask user if they want to delete the file or not #this print out all files dir=/root/etc/ find $dir -name "*.txt" output: 1.txt 2.txt etc but what i really want is 1.txt delete(Y/N): 2.txt ... (11 Replies)
Discussion started by: Calypso
11 Replies

6. UNIX for Dummies Questions & Answers

Renaming duplicate files in a loop

Hello, I have a bunch of files whose names start with 'xx' The first line of each file looks something like: a|...|...|...|... , ... In order to rename all of these files to whatever's between the 4th | and the comma (in the first line of that particular file) , I have been using: for... (2 Replies)
Discussion started by: juliette salexa
2 Replies

7. Shell Programming and Scripting

Loop to process 2 files with same name in different path

Hello forum members, I hope you can help me with this I don't know hot to reach. I have a list of files in "/home/MyPath1/" and in "/home/MyPath2/". The files have the same name in both folders. (but different content, the content doesn't matter here I think) /home/MyPath1/ filename1.txt... (4 Replies)
Discussion started by: Ophiuchus
4 Replies

8. Shell Programming and Scripting

List directory name (only once) after multiple file extensions found

Here is a simplified example of my problem. Say I have the following 3 sub-directories; ./folder1 A.txt A.sh ./folder2 B.txt ./folder3 C.txt C.sh I would like to list the directory names which contain both '.txt' & '.sh' type extensions. I have came up with the following code;... (8 Replies)
Discussion started by: mmab
8 Replies

9. Shell Programming and Scripting

Loop renaming files w/ a count problem

:wall: Hello there, basically in my program where im stuck at is when it comes to rename the files in a loop. - the program counts the number of files w a given name (works!) - and then if the number of files is greater or equal to the MAX_VERSIONS (numbers of files allowed w the... (1 Reply)
Discussion started by: thurft
1 Replies

10. Shell Programming and Scripting

While loop a file containing list of file names until the files are found?

Hi, I have a control file which will contain all filenames(300) files. Loop through all the file names in the control files and check the existence of this file in another directory(same server). I need to infinitely(2 hrs) run this while loop until all the files are found. Once a file is found,... (5 Replies)
Discussion started by: laknar
5 Replies
GPIV_SERIES(1)						      General Commands Manual						    GPIV_SERIES(1)

NAME
gpiv_series - Script for (parallel) processing a series of numbered files. SYNOPSIS
gpiv_series [-a | --arg_n] [-b | --basename FILE] [-e | --ext ext] [-f | --first N] [-l | --last N] [-i | --incr N] [-x|| --prefix] [-h | --help] [-n | --none] [-p | --print] [--pad] "process -key1 ..." DESCRIPTION
gpiv_series processes a series of numbered files. If no parameters are defined at the command line, standard parameters will be used that are defined in the script. Principally, any program or script may be invoked by gpiv_series. "Process" is a string which represents the name of the program to be executed, including eventually command line options and arguments. The file to be processed, as constructed from -b c.s., will be appended to the "process" string. If the program has to be feeded with -f "filename", write -f at the end of the string. When using the parallelised version, mpipython is invoked and the script may be launched with mpirun. The script needs that all input files are accessible on each node by copying all data or by (NFS) mounting the File System containing the input data on each node. This program does not use the parameter resources from libgpiv. Options -a | --arg_n If the process needs the current number in its argument list instead of prepending/appending it to the FILE, the number will be put before (-f) filename in the "process" string. -b | --basename FILE The FILE has to be given without its extension. FILE represents the file name without its number. It is supposed that the leading or ending number in the filename is the counter that will be applied by gpiv_series when processing. -e | --ext EXT add an extension EXT after the filename (without the leading ".") in "process". -f | --first N Defines the counter N of the number at which the analyses starts. Default: 0. -l | --last N The last number N that will be processed. Default: 0. -i | --incr N Increment number with N. Default: 1. This might be useful, for example, if subsequent numbered images are combined for cross-corre- lation with the gpiv_img2gpiv tool. -x | --prefix Use prefix numbering to file basename. -h | --help On-line help. -n | --none Suppresses real execution, only prints the process to stdout. -p | --print Prints the process to be performed on each file to stdout. --pad N Padding a number with N zero's when combining with the filename. SEE ALSO gpivtools NOTES
AUTHOR
Gerber Van der Graaf BUGS
The parallelised script has only been tested with the LAM version of mpipython. 19 Januari 2005 GPIV_SERIES(1)
All times are GMT -4. The time now is 03:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy