Visit The New, Modern Unix Linux Community

Top Forums Shell Programming and Scripting want to move files in a dir into different directories based on the filename Post 302402537 by amitranjansahu on Wednesday 10th of March 2010 05:12:17 AM
Originally Posted by devtakh
In Ksh:
for file in *.txt
dirname=`echo $file | cut -d '_' -f3`
mv $file $dirname/

Devaraj Takhellambam

Just added OLD_ to the dir name

for file in *.txt
dirname=`echo $file | cut -d '_' -f3`
mv $file $path1/

Test Your Knowledge in Computers #292
Difficulty: Easy
In 2011, Google introduced the Chromebook, a web thin client running Android..
True or False?

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to move files into different folders based on filename

I need to move a bunch of files into folders that have the same name. I wanted to either do this with some filter command or some type of batch file that I could save that would already include all of the mv commands since I will have to do this process often. Whatever method you think is easier. ... (7 Replies)
Discussion started by: italia5
7 Replies

2. Shell Programming and Scripting

grep files without header and move to new dir

Hi, i have number of files in a directory to be processed. the problem is some of the files does not have a header and the process is giving an error of no header found. example of good file : file1 HDR|20080803233401 record 1 record 2 TRA|2 example of a bad file in the same dir ... (6 Replies)
Discussion started by: sitaldip
6 Replies

3. Shell Programming and Scripting

need to move files of particular day from one dir to another dir

Hi, I have hundered's of files of the name CMP_PORT_IN_P200903271623042437_20090328122430_err.xml in error directory of todays date ie 20090328 and in the file name 5th field specifies date only now i want to move all files of 20090328 to another directory i.e reprocess directory. So... (3 Replies)
Discussion started by: ss_ss
3 Replies

4. UNIX for Dummies Questions & Answers

want to move files in a dir into different directories based on the filename

I want to move the files in a dir to different dirs based on their file names. Ex: i have 4 different files with name - CTS_NONE_10476031_MRL_PFT20081215a.txt CTS_NONE_10633009_MRL_PFT20091020a.txt CTS_NONE_10345673_MRL_PFT20081215a.txt CTS_NONE_10872456_MRL_PFT20091020a.txt and the 1st... (2 Replies)
Discussion started by: Sriranga
2 Replies

5. Shell Programming and Scripting

Move file based on filename

Hi All I need a script to manipulate files based on a filename: example filename: 66600_042706.pdf the script will create a directory 66000 only if this directory is not existing. If that directory is existing it will just move the file to 66000/666000_042706.pdf in addition, i want to... (4 Replies)
Discussion started by: aemestech
4 Replies

6. Shell Programming and Scripting

Move files based on date in filename

I know this gets covered quite a bit in the forum and I think there is enough there for me to figure out how to do what I am trying to do, I just don't think I would do it very efficiently so I am going to ask the question... I have database log files with date and time stamps in the file like ... (7 Replies)
Discussion started by: slatoms
7 Replies

7. Shell Programming and Scripting

Need a script to move the files from one dir to other other dir

Need a script to move the files from one dir to other dir and at the same time it has to read the log in the source dir. Please help me ASAP. (4 Replies)
Discussion started by: viswanathkishor
4 Replies

8. Shell Programming and Scripting

Move all files from source to destination directory based on the filename

Move all files starting with a specific name to different directory. This shell script program should have three parameters File Name Source Directory Destination Directory User should be able to enter ĎAB_CD*' in file name parameter. In this case all the files starting with AB_CD will... (1 Reply)
Discussion started by: chetancrsp18
1 Replies

9. Shell Programming and Scripting

Script to move all files in a dir into a certain dir

Hello all, I'm very new to shell scripting and need quite urgently to do this thing for my student job. I have a directory called "vectors" with a bunch of files all named ".vector". also i have for each of those files a directory with the name . I now want to move each of those *.vector files... (2 Replies)
Discussion started by: sherresh
2 Replies
DH_MOVEFILES(1) 						     Debhelper							   DH_MOVEFILES(1)

dh_movefiles - move files out of debian/tmp into subpackages SYNOPSIS
dh_movefiles [debhelperoptions] [--sourcedir=dir] [-Xitem] [file...] DESCRIPTION
dh_movefiles is a debhelper program that is responsible for moving files out of debian/tmp or some other directory and into other package build directories. This may be useful if your package has a Makefile that installs everything into debian/tmp, and you need to break that up into subpackages. Note: dh_install is a much better program, and you are recommended to use it instead of dh_movefiles. FILES
debian/package.files Lists the files to be moved into a package, separated by whitespace. The filenames listed should be relative to debian/tmp/. You can also list directory names, and the whole directory will be moved. OPTIONS
--sourcedir=dir Instead of moving files out of debian/tmp (the default), this option makes it move files out of some other directory. Since the entire contents of the sourcedir is moved, specifying something like --sourcedir=/ is very unsafe, so to prevent mistakes, the sourcedir must be a relative filename; it cannot begin with a `/'. -Xitem, --exclude=item Exclude files that contain item anywhere in their filename from being installed. file ... Lists files to move. The filenames listed should be relative to debian/tmp/. You can also list directory names, and the whole directory will be moved. It is an error to list files here unless you use -p, -i, or -a to tell dh_movefiles which subpackage to put them in. NOTES
Note that files are always moved out of debian/tmp by default (even if you have instructed debhelper to use a compatibility level higher than one, which does not otherwise use debian/tmp for anything at all). The idea behind this is that the package that is being built can be told to install into debian/tmp, and then files can be moved by dh_movefiles from that directory. Any files or directories that remain are ignored, and get deleted by dh_clean later. SEE ALSO
debhelper(7) This program is a part of debhelper. AUTHOR
Joey Hess <> 11.1.6ubuntu2 2018-05-10 DH_MOVEFILES(1)

Featured Tech Videos

All times are GMT -4. The time now is 09:41 PM.
Unix & Linux Forums Content Copyright 1993-2020. All Rights Reserved.
Privacy Policy