Tag Info

New answers tagged

1

assuming you are ok with a flat destination folder (everything moved to the same place): find /<top_level_folder> -type f -ctime -365 -exec cp -f {} /<new_folder_destination> \;


0

I believe you wanted the same thing I did, and the above answers didn't hit it quite right. I want to use rsync to copy all these directories [from a list] preserving its absolute path to another location So, put the list in a file, one directory/file per line. Don't precede with a + or trail it with some funny combination of * Use rsync's ...


1

You can try a couple of find commands like this: mkdir FULL-PATH-TO-COPY cd SOURCE find . \( ! -regex '\.' \) -type d -exec mkdir FULL-PATH-TO-COPY/{} \; find * -type f -exec ln -s `pwd`/{} FULL-PATH-TO-COPY/{} \;


2

Your script interpreter is set to /bin/sh. On the system that expands the braced list, you are using the Bourne Again shell as /bin/sh. On the system that treats the braces as ordinary (non-meta) characters, and complains that the wildcard doesn't match anything, you are using the Debian Almquist shell as /bin/sh. Your interactive login shell is almost ...


0

you can use find without ‍‍-exec‍ as well: mkdir /path/to/dest cp `find /path/to/source -name "*.jar"` /path/to/dest


1

The error message cannot stat `*.{html,txt,php}' from cp indicates that either: No matching file exists, or You are using a shell that doesn't do brace expansion. Which shell are you using on the system where the command fails? If it isn't bash but instead sh or dash, then that may explain what you are seeing. You could try giving your command *.html ...


3

Here's the solution on non-embedded Linux and Cygwin: cp -as SOURCE COPY


0

Something like this will do what you need. #!/bin/bash # SOURCE="$1" COPY="$2" cd "$SOURCE" find . | sed 's!^\./!!' | while IFS= read ITEM do test -d "$ITEM" && { mkdir -p "$COPY/$ITEM"; continue } BASE="${FILE%\/*}" ( cd "$COPY/$BASE" && ln -s "$SOURCE/$ITEM" ) done Directories are created in the ...


0

I would start by breaking out the perl: #!/usr/bin/perl use strict; use warnings; use File::Find; my $src_dir = "/full_path/to/dir"; my $tgt_dir = "/path/to/new/location"; sub link_or_mkdir { #current file is directory if (-d) { #extract the path my $newpath = $File::Find::dir; #change the path so 'old' and 'new' are ...


0

If there are not empty dirs in SOURCE which need to be copied find /full/path/to/SOURCE -type f -exec cp -t COPY --parents -s {} + mv COPY/full/path/to/SOURCE COPY rm -r COPY/full


0

It seems you are looking for something like the tool rsnapshot; it creates copies of arbitrary directories and uses hardlinks where possible. (Have a look at the man page to see whether that fits.)


3

You can use find for this. You use the folder above the folder1, folder 2 etc and execute these commands there. find /folder/ -type f -name "*.jpg" -exec cp {} "jpgfiles/" + find /folder/ -type f -name "*.mov" -exec cp {} "movfiles/" + /folder/ is the parent folder here. you need to modify it to your parent folder. EDIT: Thanks to @godlygeek for ...


1

mount ftp resource locally with: curlftpfs [user@]host:[dir] mountpoint [options] and do whatever you like like a local filesystem


0

Copy your commands and put them in a script, call it something like filecheck.sh. So the script will look something like this: #!bin/bash #THE DIRECTORY THE ORIGINAL FILE IS STORED IN MYDIR="/Users/Stu/Documents/Hoffi Work/FTP Backup Shell Script/Original" #THE DIRECTORY THE BACKUP FILE WILL BE STORED IN DEST="/Users/Stu/Documents/Hoffi Work/FTP Backup ...


1

You could use rsync instead of cp: rsync -R "${CURRENTDIRECTORY}"/"${NEWESTFILE}" "${DEST}" To limit the output path to be relative to MYDIR (for example test1/zip12.zip) you will have to enter the directory before find loop: cd $MYDIR and later find .. If you keep old files in backup directory you could even replace the whole script using rsync ...


5

You will receive in destination_dir files with full path from / find /path/git_directory -type f -iname "*.py" \ -exec cp --parents -t /path/destination_dir {} + Other solution is rsync rsync -Rr --prune-empty-dirs \ --include="*.py" \ --include="**/" \ --exclude="*" \ /path/git_directory ...


25

Use rsync with the --partial option rsync -av --partial sourcedir user@desthost:/destinationdir The --partial will keep partially transferred files. When you resume the rsync transfer after a ssh broken connection, partially transferred files will start resuming from the point where the ssh connection was lost, and also successfully transferred files will ...


2

Assuming the *frames directories are all in the same directory, you can do something like cd to/the/parent/of/the/frames/dirs mkdir all-my-raws cp *.frames/*.raw all-my-raws/ To avoid duplication of files you can replace cp with ln to just create a new link to the same data.


1

You can use find for this. find /path/to/directories -type f -name "*.raw" -exec cp {} /new/path \; If you want to move the files instead of copying them, replace cp with mv After moving the files you can remove empty directories with find /path/to/directories -type d -empty -exec rmdir {} \;


-1

My proposed solution: Collect list of all directories in a bash array. Something like dirs=($(ls *.frames)) This way you will have all the directory names in an array. Run a loop for the entire range with something like for i in ${$dirs[@]}; do...... Within the loop, create a new directory somewhere, & move all files from current directory to that ...



Top 50 recent answers are included