Hot answers tagged

5

$src = "G:\temp" $target = "G:\notalone" if (Test-Path $src) { $folders = Get-ChildItem $src -Recurse | ?{ $_.PSIsContainer } foreach($folder in $folders) { $fc = Get-ChildItem $folder.FullName | ?{!$_.PSIsContainer} | Measure-Object | Select-Object -Expand Count if ($fc -eq 1) { $file = Get-ChildItem ...


4

@echo off Setlocal EnableDelayedExpansion SET ROOT_FOLDER=C:\TEST 1 SET TARGET_FOLDER=C:\TEST 2 FOR /D %%G IN ("%ROOT_FOLDER%"\*) do ( CD %%G FOR /f %%A in ('dir ^| find "File(s)"') do ( set cnt=%%A Echo %%G : !cnt! IF !cnt! == 1 ( move /-y "*.*" "%TARGET_FOLDER%" ) ) ) This Batch will look inside ...


3

The short answer is no. For that functionality, you’d have to write a script that recurses through each sub-directory (either depth-first or breadth-first) and can efficiently saves its state in a temporary file to allow its resumption. It would be a non-trivial (but interesting) exercise and I’d recommend a high level scripting language such as Perl, ...


3

Your problem is that the find command does not interpolate/interpret directory glob(s) (the directory list that it must seek under), it only interpolates the pattern as a glob that must match. What interprets the directory globs is the shell itself you run find inside. When you run find via ssh, there is no shell to do this job. Luckily enough, there's no ...


2

The * is expanded by your local shell. You should quote your argument ssh Svr1 /usr/local/bin/sudo -S find '/path/*/foo/' -name "20160208"


1

As @Matteo said, you need to escape the * from your local shell. He's done that in his first example: ssh Svr1 /usr/local/bin/sudo -S find '/path/*/foo/' -name "20160208" As alternative, either of these should work as well, as the single quotes ('...') and backslash (\) "hide" the * wildcard from your local shell: ssh -t Svr1 /usr/local/bin/sudo 'find ...


1

Another approach find . -name '*.txt' -exec rsync -R {} path/to/dext \;


1

Currently trying this one out, but maybe something like this: for dir in `find . -type d -mtime +30`; do find $dir -type f -mtime -30 -quit -o -print; done


1

I realise you posted your own answer, but in case you wish to use the REGEX syntax you are, you can change the REGEX type using this command: -regextype TYPE So I believe to make yours work: find /path/to/images/ -regextype sed -regex '.*(26[2-7]|27[0-2]).*' -exec echo {} \; may do the trick. Also, just a note, your regex will match anything with ...


1

There also is an -or (or -o) operator to the find command. You could divide your expression in two subexpressions: find /path/to/images/ -regex ".*(26[2-7]).*" -o -regex ".*(27[0-2]).*" -exec echo {} \; -o is POSIX compliant, while -or is not: As per the find man page: expr1 -o expr2 Or; expr2 is not evaluated if expr1 is true. expr1 ...


1

Try this: find -name .git -execdir sh -c 'test $(git remote)' \; -execdir git fetch \; and because that starts a shell anyway, you can even do: find -name .git -execdir sh -c 'test $(git remote) && git fetch' \;



Only top voted, non community-wiki answers of a minimum length are eligible