• Post Reply Bookmark Topic Watch Topic
  • New Topic

Moving files to a folder  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a script to move files of type .txt to a particular folder .It looks for the files in work folder and move it to completed folder.
Example: It takes the .txt file from /tmp/swan/test/work to /tmp/swan/test/completed, but would like the script to also move the files from a subfolder to the completed folder. Example : Files from /tmp/swan/test/work/APX should move to /tmp/swan/test/completed

Below is the current script.

#!/bin/bash

MY_DIR=/tmp/swan

cd $MY_DIR

find . -path "*work*" -iname "*.txt" -type f -execdir mv '{}' ../completed\;
 
Ranch Hand
Posts: 417
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Find already looks in subfolders

What is the output of your script?

find . -path /tmp/swan/test/work -iname "*.txt" -type f -execdir mv '{}' ../completed\;

should work

When you are in the /tmp/swan folder, nothing seems to match "*work*" so find doesn't find a path to search from.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!