Ubuntu :: Write A Bash Script Which Will Find Files Then Move Them To A Specific Directory?

Sep 1, 2011

I'm trying to write a bash script which will find files then move them to a specific directory.

So far I have:

Code:
#!/bin/bash
#script to find and move files
src_dir="/path/to/source/directory"
des_dir_mov="/path/to/destination/directory/for/movies"
des_dir_img="/path/to/destination/directory/for/images"
find $src_dir -iname '*.avi' -type f -exec mv '{}' $des_dir_mov ';'

I'd like to have all the possible movie file types then the image file types checked in a loop.

Every time I try to include an array in this script it breaks

View 3 Replies


ADVERTISEMENT

General :: Find Files With Specific Extension And Move To A Directory?

Apr 18, 2011

I need little help. I want to find all files with extension "*.tar" "*.gz" and "*.zip" and move all those files into "/opt/old" directory. I've tried this command:

Quote:

find . -type f -name "*.tar" "*.gz" "*.zip" -print0 | xargs -0 -r mv /opt/test

It's not working, something wrong after "mv" i guess.

View 10 Replies View Related

General :: Write A Script To Move Specific Files In Various Folders To One Folder?

Nov 16, 2010

Terribly new to Linux and find it mindboggling. I work on brain imaging and unfortunately all of the analysis runs on Linux, and I do not understand computers well coming as I do from a medical background. So my question - There are various folders of patient MRI scans (folders called P1, P2, P3 etc) and within them are enclosed certain files that I am interested in (always called the same name in all folders, say image001). I would like a script that enables me to copy and move this image001 in all these individual folders to another folder altogether.

View 13 Replies View Related

General :: Write A Bash Script That Gets The List Of Files In A Directory?

Apr 5, 2010

I'm trying to write a bash script that gets the list of files in a directory and puts them into a variable, then checks each entry and outputs them as follows:

item1 is a FILE
item2 is a DIR
item3 is a DIR
etc etc.

I am able to get the list of files into a variable, but unsure how to get the output I want.

View 3 Replies View Related

Programming :: Check Folder For Specific Files Than Move Script?

Nov 16, 2010

I have a script that checks a folder for zip files than moves them to a different folder. I want to check every 5 maybe 10 seconds and since cron is setup to run at least a 1 minute increment I'm not sure how to do that time check as probably a loop within the script. One other thing is once the time check is in the script how would a cron job be setup to run this script? Once the script is running cron doesn't need to run it again, is there a feature to check if it's running and if it's not then run it?

find /export/xxxshare -name "*.zip" -exec mv {} /export/store ;

View 3 Replies View Related

General :: Cannot Move A File Into My Archives Directory In Bash Scrip

Apr 12, 2010

I cannot move a my file into my archives directory in my bash scrip.

View 7 Replies View Related

Server :: Can't Write Files To A Sub-directory Of The Chroot Directory

Jul 20, 2011

I'm using OpenSSH 5.5p1 on Fedora 15. I'm trying to get a chrootDirectory to work. Specifically trying to figure out why I can't write files to a sub-directory of the chroot directory. I created a user test_user and created a group called sftp. I added test_user to the sftp group. I edited /etc/ssh/sshd_config as follows:

Code:

Subsystem sftp internal-sftp
Match group sftp
ChrootDirectory /home/sftp_users/%u
X11Forwarding no

[code]....

View 1 Replies View Related

Debian :: Find All Pictures And Move Them To One Tmp Directory?

Feb 16, 2010

I have directory with sub directories in it. Inside I have bunch of pictures. I would like to find all pictures, and move them to one tmp directory. While moving there might be files with same names. The command I use:

--- find . -name '*JPG' -exec mv -i {} /home/xxx/xxx/xxx/Pictures/2004/tmp ; ---

now the problem comes with overwrite if there are two files with same name. Is there any simple way to copy all files into one directory and not to loose any, appending certain, even random char, to the 2nd file would do.

View 2 Replies View Related

Programming :: Write A Bash Script That Continue Monitor The Tmp Directory?

Dec 25, 2010

In my tmp directory some logs are creating continue (with name logs.txt1, logs.txt2 up to 245). Some times these logs are creating continue within 1 or 3 second gap, now I want to write a bash script that continue monitor the tmp directory and if any time logs create simultaneously within 1 or 3 section gap it will alert me..( generally logs are create with the gap of 5 or 10 minutes duration or some time after one hours )

View 1 Replies View Related

Ubuntu :: BASH Script To Move Files More Than 30 Days Old?

May 12, 2011

I need to move files to a backup drive if they are over 30 days old. All I could find, when looking for scripts, were ways to sort files by date and the solutions were all over the place and nothing seemed simple or good.

I've thought of building my own running "ls -al > filelist.txt" type of approach and then processing the file, but not sure that is best way. An array would be much easier and eliminate the file, but never done an array in bash.

View 9 Replies View Related

Ubuntu :: Script Or Command To Move Files To Directory Of Same Name

Mar 12, 2010

I'm doing a little work on my media center and the scrappers seem to do a much better job when each movie is in a directory with the name of the movie. However that's not how i have things set up.I have a few hundred avi files i need moved to directory named the same as the avi file.

View 3 Replies View Related

Ubuntu :: Copy / Move Random Files From One Directory To Another

May 7, 2011

We have two folders: source folder and destination folder. In source folder we have many sub folders and many files of different type!Script that would copy or move defined number of files from source to destination folder. Files must be selected randomly and sub folder in source folders must be selected randomly and we don't copy or move defined number of files just form one sub folder in source folder. In destination folder sub directory structure of source folder should not be preserved. Solution should be robust and as simple as possible.

View 9 Replies View Related

Ubuntu :: Move Files From Folder/subfolders To A Different Directory?

Jan 10, 2011

I would like to know how to move all the files from a single folder and its subfolders to a single, different location in as few steps as possible. For example when I download files from one of my school's websites, the file I want is located in a deep sub-directory. So, I have to cd many times just to get to the file I want. Is there a way to recursively move all the files within a folder's subdirectories into a new location?

View 2 Replies View Related

Programming :: Bash Command To Remove All Files Within A Specific Folder?

Oct 19, 2010

I want to delete all files within a specific folder without actually deleting the folder, what is a good bash command for this?. I found this one but encountered some errors even though I am executing it within the specific folder:

useratdebian:/home/user/folder# find . -type f -exec rm -rf {} ;
[1] 5052
useratdebian:/home/user/folder# find: missing argument to `-exec'
[1]+ Exit 1 find . -type f -exec rm -rf

The command as it appears is:

find . -type f -exec rm -rf {} ;

how to delete only the files contained within the folder called "folder" for example?

View 4 Replies View Related

Programming :: Bash Script: Move Files To Trash Instead Of Deleting?

Jul 10, 2010

I've tried a number of suggestions found on the internet and none of them work. Here's one:Code:mv "$x" ~/.Trash/...where $x is the pathname of the file passed to the script.I've also tried different paths to Trash - on Desktop, in Home folder, in my user folder, it makes no difference. Either nothing happens, or more often, the file is simply copied to my desktop or userfolder with the name "Trash".What is the actual path to the Trash folder and how can I move files there? I'm using Ubuntu 10.04.

View 1 Replies View Related

General :: Move Files To Another Directory Using A Cron Job?

Sep 29, 2009

I have a php script in cron directory that generates 5 textfiles, after the files are generated, I want to create a script that will move the 5 text fiels to anoher folder name "web".

View 2 Replies View Related

General :: Move All Files And Folders Into A New Directory?

Jan 25, 2011

Unix - In Linux, how do I move all files and folders into a new directory?

View 4 Replies View Related

Ubuntu :: Move Music Files From All Subdirectories To Parent Directory?

Mar 1, 2010

I've found several posts discussing how to do this in with the terminal, but none exactly fit what I am trying to do. And since I'm still very new, I was hoping for some help.

I have a parent directory called "Music." The subdirectories all start with "artist", some go further as in "artist/album/cd1". So right now the structure varies in the following ways code...

How can I move all the files (or the file types that I choose) to the parent directory "music"?

(By the way, for any who are interested, this is so that I can use an external hd with a PS3. ("playstation 3"--for anyone who was in my predicament searching the threads)

View 7 Replies View Related

General :: Xargs And Unzip All Files To Specific Directory?

Jun 22, 2009

I'm trying to find all zip files timestamped from the past 7 days, then unzip them into a different director.I tried the following, but it only unzipped one of three files that meet the 7 day criteria. What am I missing?Code:find /home/user/public_html/zip_files/ -iname "*.zip" -mtime -7 -print0 | xargs -n10 unzip -LL -o -d /home/user/public_html/another_directory/

View 1 Replies View Related

General :: Move 1 File To A Directory Containing 3 Million Files?

Jul 25, 2011

the system currently have a directory with all the invalid files. how bad is it to move a single file to a directory containing 3 million files already?

View 2 Replies View Related

General :: Find Directory Older Than X And Mv Directory With Sub Files Command?

Jul 13, 2011

I'm quite new to linux but I have configured a simple ftp server and it's working great. I have a FTP-Shared folder with upload and download subfolders. Under upload's and download's I have identical category subfolders like mp3's, movies, software etc. in both. As the guy's upload, I would like to create a line crontab where I can move all the content under /FTP-Shared/upload/mp3/* older than 14 day's to FTP-Shared/downloads/mp3/ recursively (Like in cp command), but the timestamp must be searched on the first directory and not sub files example: /mp3/Club Dance/CD1/Hallo world.mp3This is how far I got:[root@clients ~]# /usr/bin/find /FTP_Shared/upload/Mp3s/ -depth -mindepth 1 -mtime +14 -type d -exec mv -f {} /FTP_Shared/download/Mp3s/ ;This command moves the directory and files, but it is not recursively

View 4 Replies View Related

General :: BASH Script To Move Files/folders To Either The .Trash File Or To Another Direcotry?

Dec 2, 2010

I am looking for a script/advice or guidance on how to write a script so that when I use the 'del' command it removes/sends the files/folders to a I specify for example 'dustbin

View 13 Replies View Related

General :: Forbid Removal Of Files But Allow Creation Of Them For Specific Directory?

Jun 14, 2010

I have an application that creates temp files and quickly deletes them. But I'd like to keep those files, is there a way to do that in Linux?

View 2 Replies View Related

General :: Overwriting Specific Files In Directory Tree Recursively

Jul 19, 2011

I would like to overwrite files in a directory tree, recursively. The ones I would like to overwrite match the filename "x_alpha*.png" and have a size exactly 456 bytes. Is there any way to search for these recursively in a directory tree, and overwrite them with a reference file, for example "e:mydirgood.png"

I am using Windows 7, but I have UnxUtils, so I can use those too. What I am looking for is something like this, generated automatically:
copy /y e:mydirgood.png e:mydiracx_alpha0023.png
copy /y e:mydirgood.png e:mydirefgx_alpha0045.png
copy /y e:mydirgood.png e:mydirhx_alpha0248.png

View 2 Replies View Related

General :: Searching A Specific Directory For Files Containing A Text String?

Nov 20, 2010

I am a member of a group which has written a program whose source code is being held in a specific directory (~cs252/Assignments/basicAsst/project) and we want to go through and change the parameters for the function "sequentialInsert." My job is to find all occurances of the function call to "sequentialInsert" and to also list the files from where the code came from. Also, I have to be in the commandsAsst directory when I do this. I have tried grep and find combined together, and I am at a lost.

View 1 Replies View Related

General :: Auto Unrar Files And Move Whitelist To Another Directory

May 10, 2011

I'm looking for a script that can be run regularly with Cron.

Check a folder for Rar files every few minutes, Unrar if present, and delete the left over files once done.

Be able to specify the directory of which folder to watch within the script.

Run an extension white list (.avi, .mkv, .mp4) and blacklist (rar files) of files to be moved.

Specify within the script which folder to move found files to.

I've seen a few online that does some of this or much more than this but I'm looking for something that just does this in a simple and efficient way... (Also for the life of me, I just can't get how to edit this to do what I'm looking for)

View 17 Replies View Related

Ubuntu :: Find And Move Commands On Large Number Of Files ?

Feb 21, 2011

We recovered a large number of files from a HD I messed up. I am attempting to move large numbers of files of a type e.g. .txt .jpg , into a folder by type to more easily sort through them.

Here are the commands I have mainly been trying with various edits:

Code:

Code:

So far the most common complaint I have gotten "missing arguments to execdir".

This is on Ubuntu 10.04

View 6 Replies View Related

Programming :: Simple Bash To Write Files By Year To A Log File

Jan 31, 2011

I have a folder of 2 many files that the old ls just hangs.

I am trying to write some log files such as;

I don't mind doing one at a time, but I am just playing and even getting the listing I am not getting the date stamp, I have the following;

That does create the file, but all the files look like this;

So basically it's just sticking that ls inside the log file and not actually running the ls, so how can I use the above type to get files just created per year?

View 2 Replies View Related

Programming :: Write A Script That Will Go Through The Files In A Directory?

Nov 19, 2008

How can I write a script that will go through the files in a directory and print on the screen the name of the files stating if it is a file or directory. The directory is already provided by the user.

View 12 Replies View Related

General :: Find And Move Files Greater Than 15GB?

Jan 23, 2010

I have a Ubuntu NAS set up with two 1.5TB in a mirrored array. We recently needed more storage and will constantly be adding to this machine. We added 2 2TB drives in a striped array. What I'd like to do is find all directories totaling 10GB+ on the mirrored array and move them over to the striped array to increase storage on the mirrored array for smaller, more important data. I've tried:

Code:
find /mirror -maxdepth 1 -size 10G
find /mirror -size 10

[code]....

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved