Questions tagged [recursive]

Operating on a directory and its subdirectories, recursively.

Filter by
Sorted by
Tagged with
0
votes
0answers
29 views

Is it possible to convert all video files in subdirectories on google drive using ffmpeg & rclone?

Currently I'm using this code whereby rclone fetches 1 file from my google drive, converts it using ffpmeg on a server and moves the converted files to the same folder. It's shown as below. Step 1 is ...
0
votes
1answer
27 views

Updatedb on samba mounted shares

I have a few directories mounted from a samba share server (my lan storage) and I would like to run updatedb on them. I use to successfully run such command to do that: updatedb -l 0 -o ~/.myDbFile....
0
votes
2answers
54 views

Unix how to copy file to directory and echo

I am trying to write a script using a for loop to copy files to a directory that will also echo the copy command to the terminal. I have successfully gotten the script to copy files, however, am ...
1
vote
1answer
27 views

Append file name to beginning of [Markdown] file recursively

I have a folder with a whole lot of folders with a whole lot of Markdown files in each. What I'd like to do is recursively (if possible) prepend the file name as a heading in each file. So, given foo....
1
vote
1answer
30 views

Recursive thumbnail creation to different destination

I wish to show my photo collection on my television. In order to do this, I need to resize the photos to fit in a 1920x1080px window (because the performance is awful when dealing with the originals). ...
0
votes
1answer
94 views

Flattening directory and renaming files incrementally (MacOS)

Looking to flatten the directory (with duplicate child file names) while renaming all files, keeping duplicates OR appending all file names with an incrementing number (incrementing # + name would be ...
0
votes
1answer
110 views

How may I emulate the -R feature of “zip”, but in gzip and xz?

The program "zip" has a -R feature which allows one to zip all files with a certain name in a directory tree: zip -r v/s zip -R For example: zip -R bigfile "bigfile" Will zip all of the following: ...
3
votes
5answers
119 views

Moving all files with same file extension .txt to a new directory

Basically, my hard drive is a mess and I have like 200+ sub-directories in a main directory. I want to essentially move all files in 200+ sub-directories that have the extension .txt etc to a new ...
0
votes
2answers
27 views

Command to recursively delete all files with changing extension number

I know how to delete recursively all files with a specific extension, but how about if that extension has a number appended to it? For example, how can I delete files named .d3plot1, .d3plot2, ....
0
votes
0answers
47 views

Recursively Find and Copy All PDF files from HDD to a Local Folder

I'm trying to copy all PDF files in an HDD to my computer, without losing any PDF files with different content but the same name, i.e. if I have 3 folders folder1, folder2 and folder3, each with a ...
1
vote
2answers
147 views

how to unzip a zipped file which include various zip level files in unix/linux? [duplicate]

For example my folder name is Test.zip Test.zip includes various zip folders like te1.zip, te2.zip , te3.zip even te1.zip include various zip folders. So i need to unzip in linux at once. Could ...
0
votes
3answers
65 views

Sort output of find command, read back in to remove files

The following bash script searches through all directories and tabulates how many files are in each directory. Sample output testing on my own R installation is below - exactly what I need. find . -...
0
votes
1answer
40 views

Recurse massive dir structure, delete files over X days

First linux coding job. Told to make a script for a chron job that dives through all folders on server and deletes any files over X days (probably 20). I have tested the code below on my home ...
1
vote
2answers
42 views

Wrong result when recursively count lines with wc

I am using the following Linux command to recursively count lines of text files in a folders structure: find . -name '*.txt' | xargs -d '\n' wc -l This outputs all found files and their number of ...
0
votes
1answer
48 views

How to recursively find file, concatenate into one file and simultaneously delete the original file

As I understand it, I could use find . -name '*.txt' -exec cat {} \; > all.txt to concatenate all the text files in a directory, recursively throughout sub-directories, into a file called all....
0
votes
2answers
149 views

How do I make this rsync command non-recursive?

rsync -avi --delete --modify-window=1 --no-perms --no-o --no-g ~/Documents/Stuff/ /media/user/PC/Stuff;; i.e. to not copy sub-directories from the source directory?
0
votes
0answers
21 views

rsync only folders that exist in target

Trying to use rsync to move some directories around, and I'm a bit stumped. Using the --existing argument copies the files only if they exist in the target directory, but that's not quite what I'm ...
1
vote
1answer
288 views

Grep contents recursively, print only 1 directory level deep

I want to search within file contents, recursively on subdirectories, but I only care about whether the first level subdirectory contains any matches. That is, given: ParentDirectory ...
0
votes
2answers
52 views

Copy folders to another set of directories, only if folders already exist

I want to copy (overwrite) folders from one directory to another set of directories, only if the folders in directory1 exist in directory2. For example, I have stored some folders in my home ...
-2
votes
2answers
342 views

cp -a doesn't work to copy all files inside a directory

I desire to copy all files inside a directory which has only these files (all are regular files - there are no directories, symlinks, etc, inside that directory) to another pre-existing directory. The ...
1
vote
2answers
100 views

Recursively flattening subdirectories in a root directory and maintaining level 1 sub-directory structure

I have a large n-level directory structured as follows: root | subdir1 | sub_subdir1 | ....(n-2 levels)..... | ...
0
votes
1answer
119 views

How do I write a shell script to flatten directories?

I wrote a simple script to delete useless files from a directory using the find command. Now I'm wondering if I can add lines to the script to flatten directories, but not completely flattened. e.g.,...
1
vote
2answers
200 views

Sort and mv files based on filename (with spaces), recursively

I have made a mistake and dumped files together into the same directory. Luckily I can sort them based on the filename: ''' 2019-02-19 20.18.58.ndpi_2_2688_2240.jpg ''' Where the # bit or 2 in this ...
1
vote
2answers
117 views

Bash recursive call fails

I am writing a function in ./bashrc to switch environment variables, commands, etc. This function is supposed to set up the necessary variables then call itself. Instead I get bash: ./bash: No such ...
-6
votes
1answer
245 views

What is the meaning of -r and -R in copy command?

I read that they stand for recursively in the man page. However, I am not sure what their role is in the command. When I tried to copy some empty directory into another directory with, $ cp EMPDIR ...
0
votes
2answers
29 views

Recursively copying a folder to an empty subfolder

How to copy all the content of the folder /foo/bar, which contains the file /foo/bar/a to an empty subfolder /foo/bar/subfolder without ending up with the file /foo/bar/subfolder/subfolder/a. Doing cp ...
0
votes
1answer
45 views

Move Files Recursively but only if they are not open by another process

I want to modify the script text below, to change the file permissions, owner and move it, only if the file is not open by another process. cd /mnt/usbdrive/DVR sudo chown 777 -R /mnt/usbdrive sudo ...
1
vote
1answer
600 views

Recursively converting Windows files to Unix files

I have a PHP application with is located on Linux with multiple directories (and sub-directories) and many PHP, JS, HTML, CSS, etc files. Many of the files have Windows EOL control characters and I ...
0
votes
2answers
206 views

Recursive conversion of jpeg files

I use this commandline to convert jpegs to pdfs inside a folder. for f in *.jpg; do echo "Converting $f"; convert "$f" "$(basename "$f" .jpg).pdf"; done However, I would like to convert all .jpg ...
0
votes
0answers
134 views

How to run command recursively on files within directory and sub-directories within? [duplicate]

How can I run the command below recursively on all directories and sub-directories within? [someone@someones-pc ~]$ for i in *.mp4; do ffmpeg -i "$i" -i watermark.png -filter_complex "overlay=1623:25"...
1
vote
1answer
869 views

Use SCP from local machine to recursively copy current working directory to remote?

Trying to do something like (in pseudo-unix): scp -r <pwd> username@remote.com:~/<dirname of toplevel> In other words, I'm trying to copy the current directory I'm in locally (and the ...
3
votes
1answer
158 views

Command “tree” vs “tree -R”

So I'm asking myself why there is the "-R" argument for the "tree" command. The manual says "-R Recursively cross down the tree each level directories ...", but I don't see any difference in the ...
1
vote
2answers
948 views

How to recursively copy a directory using cpio?

How do I copy recursively a directory within the list at my-files-to-copy.txt? cd my/source/dir cpio --create < my-files-to-copy.txt | (cd my/dest/dir && cpio --extract) my-files-to-copy....
2
votes
1answer
489 views

How to use istat on AIX like stat on Linux distributions

In Linux, I use the following command to show this output: find /backup/$INSTANCE/tsm/* -exec echo '"{}" ' \; | xargs stat --printf "chown %U:%G '%n'\nchmod %a '%n'\n" >> /tmp/permissions.txt ...
1
vote
1answer
601 views

How to search for a folder or file in parent folders [duplicate]

I tried to search for a folder in its parent folders instead of its child sub-folders (usually any search bash command will do). I need to know whether any reverse alternative for any search commands ...
0
votes
4answers
141 views

Recursively rename all the files without changing their extensions?

How to recursively rename all the files in several layers of subdirectories without changing their extensions? Below's a toned down version (to save room) of what I've got. For argument's sake, I ...
5
votes
1answer
6k views

Wget: downloading files selectively and recursively?

Question about wget, subfolder, and index.html. Let's say I am inside "travels/" folder and this is in "website.com": "website.com/travels/". Folder "travels/" contains a lot of files and other (sub)...
0
votes
2answers
377 views

setfacl -R doesn't work on Cygwin

I want to change the ACL and the default ACL for all directories and files in a base directory. In other answers (such as this one), the -R flag is used. However, I get $ setfacl -R -m u::rwx my_dir/ ...
0
votes
1answer
207 views

Copying a source directory using the command cp -rsf when target directory exists

On Centos 7, when I use the command: cp -rsf /path/of/source /path/of/target When the target directory exists, files would go to /path/of/target/source. How can I avoid that? EDIT: source and ...
0
votes
1answer
112 views

Copy files from a source folder recursively to destination/*file_extension*(ex. “txt”) folder

This is my code, something in the rec_copy() function isn't working properly, the extension named folders are created in the destination folder but the files are not copied there. #!/bin/bash if [ $# ...
1
vote
1answer
664 views

Limiting recursive 'aws s3 ls' searches by number of items in the folder

Here's the scenario: I need to recursively search through tons and tons of folders and subfolders and spit out the results to a log file using the ls command, BUT, I need to stop searching a folder ...
1
vote
1answer
517 views

Bash - Recursive directory/file rename

I have the following script, that will replace all spaces in files and directories recursively: ################### SETUP VARIABLES ####################### number=0 # Number of ...
0
votes
2answers
74 views

zip files within all sub-directories of a given parent directory

Say I have a parent_directory/ with the following sub-directories child1/, child2/ and child3/. How do I script to zip all *.txt files in childx/ into childx.zip I also want this childx.zip to be ...
3
votes
3answers
504 views

substitute with SED recursively

Is it possible to substitute a sample recursively in multi directory with grep and sed like that ? grep -e "http://localhost:4000" -r ~/dev_web/_site | sed -e 's/http:\/\/localhost:4000/https:\/\/...
2
votes
2answers
189 views

Recursively grep through epub files

I tried the answers here, but without luck. find . -name "*.epub" -exec zipgrep pattern {} \; showed me "matched", but didn't give me the matching epub file back. Also, it returned huge blobs of ...
1
vote
1answer
37 views

Inline replace comments in files recursively

I have tried using the cloc tool with the --strip-comments parameter, which is correctly stripping the comments from all files recursively, with 2 issues: it cannot do it "in-place" the resulting ...
0
votes
0answers
127 views

wget with acceptance test, redirect fails the test

I'm running the command: wget -r --wait=2 --random-wait -P ./pdfs -A pdf -e robots=off https://www.<somesite>/documents The command has worked on other sites to recursively download all pdfs, ...
-2
votes
3answers
35 views

how to know list of file types under Directories & Sub-directories [closed]

Under CentOS, how to know file types under directories & sub-directories in one command? Output should look like: .inc, .inp, .odb, .a3db, .......
0
votes
1answer
450 views

Recursively copying directories with a given name

With a directory structure built using #!/bin/bash for name in A B do mkdir -p /tmp/src/${name}/copyme echo "do not copy" > /tmp/src/${name}/no.txt echo "copy" > /tmp/src/${name}/...
0
votes
2answers
4k views

how to untar specific files recursively in linux? [duplicate]

I have lots of tar(.tar.bz2) files containing multiple file types in a recursive directory. I want to extract just one type of file(let's say .txt files) from all the directories. How do i do that? I ...

1
2 3 4 5 6