Sponsored Content
Top Forums Shell Programming and Scripting Move files from one directory to another in chunks Post 303002311 by rbatte1 on Tuesday 22nd of August 2017 05:50:49 AM
Old 08-22-2017
You could be simpler with xargs and a call to another mini-script. A starter might be something like:-
Code:
$ cat my_mover.sh
#!/bin/bash
#my_mover.sh script actually does the work

target_dir=$1                 # Grab the target directory
shift                         # Chop off the target directory to just leave all the files listed

mv $@ $target_dir             # Take all arguments and move them to the target directory
sleep 1

You can then run something like this:-
Code:
find $dir1 -maxdepth 1 -type f | xargs -n 100 $dir2 my_mover.sh

This will move 100 files at a time (specified by the xargs parameter after -n)




I hope that this helps,
Robin
This User Gave Thanks to rbatte1 For This Post:
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Move all files in a directory tree to a signal directory?

Is this possible? Let me know If I need specify further on what I am trying to do- I just want to spare you the boring details of my personal file management. Thanks in advance- Brian- (2 Replies)
Discussion started by: briandanielz
2 Replies

2. UNIX for Dummies Questions & Answers

How to move files between 2 dates from one directory to another

Hi All, I am coding for a requirement where I need to move files (filename.yymmdd) from one directory(A) to another(B) based on 2 date fields in a paramtere file. (Paramfile.txt) For e.g: In Paramfile.txt, BUS_DT =20120612 SUB_DT =20120602 In this case, i need to move all the files... (14 Replies)
Discussion started by: dsfreddie
14 Replies

3. UNIX for Dummies Questions & Answers

Zip all files in a directory and move to another directory

Hi, need to zip all files in a directory and move to another directory after the zip.. i am using this one but didnt help me... zip -r my_proj_`date +%Y%m%d%H%MS`.zip /path/my_proj mv in_proj_`date +%Y%m%d%H%M%S`.zip /path/source/ i am trying to zip all the files in my_proj... (0 Replies)
Discussion started by: dssyadav
0 Replies

4. Shell Programming and Scripting

Process files in a directory and move them

I have a directory e2e_ms_xfer/cent01 this contains the multiple files some of which will be named below with unique date time stamps e2e_ms_edd_nom_CCYYMMDD_HHMM.csv What I want to do is in a loop 1) Get the oldest file 2) Rename 3) Move it up one level from e2e_ms_xfer/cent01 to... (1 Reply)
Discussion started by: andymay
1 Replies

5. UNIX for Dummies Questions & Answers

Rename files in a directory and move them

I have a directory e2e_ms_xfer/cent01 this contains the multiple files some of which will be named below with unique date time stamps e2e_ms_edd_nom_CCYYMMDD_HHMM.csv What I want to do is in a loop 1) Get the oldest file 2) Rename 3) Move it up one level from e2e_ms_xfer/cent01 to... (1 Reply)
Discussion started by: andymay
1 Replies

6. Shell Programming and Scripting

List files with date, create directory, move to the created directory

Hi all, i have a folder, with tons of files containing as following, on /my/folder/jobs/ some_name_2016-01-17-22-38-58_some name_0_0.zip.done some_name_2016-01-17-22-40-30_some name_0_0.zip.done some_name_2016-01-17-22-48-50_some name_0_0.zip.done and these can be lots of similar files,... (6 Replies)
Discussion started by: charli1
6 Replies

7. UNIX for Beginners Questions & Answers

Move all files one directory level up

I want to move all the files in a given directory up one level. For example: Dir1 Subdir1 I want to move all the files in Subdir1 up to Dir1 (then I want to ultimately delete Subdir1) Thanks, Ted (10 Replies)
Discussion started by: ftrobaugh
10 Replies

8. UNIX for Dummies Questions & Answers

How to move gz files from one source directory to destination directory?

Hi All, Daily i am doing the house keeping in one of my server and manually moving the files which were older than 90 days and moving to destination folder. using the find command . Could you please assist me how to put the automation using the shell script . ... (11 Replies)
Discussion started by: venkat918
11 Replies

9. Shell Programming and Scripting

How Create new directory and move files to that directory.?

Hi All, We have main directory called "head" under this we have several sub directories and under these directories we have sub directories. My requirement is I have to find the SQL files which are having the string "procedure" under "head" directory and sub directories as well. And create... (14 Replies)
Discussion started by: ROCK_PLSQL
14 Replies
LN(1)							    BSD General Commands Manual 						     LN(1)

NAME
ln, link -- make links SYNOPSIS
ln [-fhinsv] source_file [target_file] ln [-fhinsv] source_file ... target_dir link source_file target_file DESCRIPTION
The ln utility creates a new directory entry (linked file) which has the same modes as the original file. It is useful for maintaining mul- tiple copies of a file in many places at once without using up storage for the ``copies''; instead, a link ``points'' to the original copy. There are two types of links; hard links and symbolic links. How a link ``points'' to a file is one of the differences between a hard and symbolic link. The options are as follows: -f If the target file already exists, then unlink it so that the link may occur. (The -f option overrides any previous -i options.) -h If the target_file or target_dir is a symbolic link, do not follow it. This is most useful with the -f option, to replace a symlink which may point to a directory. -i Cause ln to write a prompt to standard error if the target file exists. If the response from the standard input begins with the char- acter 'y' or 'Y', then unlink the target file so that the link may occur. Otherwise, do not attempt the link. (The -i option over- rides any previous -f options.) -n Same as -h, for compatibility with other ln implementations. -s Create a symbolic link. -v Cause ln to be verbose, showing files as they are processed. By default, ln makes hard links. A hard link to a file is indistinguishable from the original directory entry; any changes to a file are effectively independent of the name used to reference the file. Hard links may not normally refer to directories and may not span file sys- tems. A symbolic link contains the name of the file to which it is linked. The referenced file is used when an open(2) operation is performed on the link. A stat(2) on a symbolic link will return the linked-to file; an lstat(2) must be done to obtain information about the link. The readlink(2) call may be used to read the contents of a symbolic link. Symbolic links may span file systems and may refer to directories. Given one or two arguments, ln creates a link to an existing file source_file. If target_file is given, the link has that name; target_file may also be a directory in which to place the link; otherwise it is placed in the current directory. If only the directory is specified, the link will be made to the last component of source_file. Given more than two arguments, ln makes links in target_dir to all the named source files. The links made will have the same name as the files being linked to. When the utility is called as link, exactly two arguments must be supplied, neither of which may specify a directory. No options may be sup- plied in this simple mode of operation, which performs a link(2) operation using the two passed arguments. SEE ALSO
link(2), lstat(2), readlink(2), stat(2), symlink(2), symlink(7) COMPATIBILITY
The -h, -i, -n and -v options are non-standard and their use in scripts is not recommended. They are provided solely for compatibility with other ln implementations. STANDARDS
The ln utility conforms to IEEE Std 1003.2-1992 (``POSIX.2''). The simplified link command conforms to Version 2 of the Single UNIX Specification (``SUSv2''). HISTORY
An ln command appeared in Version 1 AT&T UNIX. BSD
December 30, 1993 BSD
All times are GMT -4. The time now is 07:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy