Sponsored Content
Top Forums UNIX for Dummies Questions & Answers move files from folder thats are not empty Post 10642 by maverick on Monday 19th of November 2001 07:21:33 AM
Old 11-19-2001
Lightbulb

Hi,

I hope this might help as I tested it very briefly.

dir_one="your directory pathway/tmp" //* directory where files could be *//
dir_two="your directory pathway/tmp2" //* directory where files moving to *//
Code:
for files in $dir_one/*.txt     //* files with "txt" extension *//            
 do                                                                           
 if [ -a $files ]               //* checks if files exists *//                
  then                                                                        
    mv $files $dir_two          //* If so they get moved to new directory *// 
 else                                                                         
   echo "no files to move"      //* the else bit could be left out * /        
 fi
done

Smilie
Maverick

added code tags for readability --oombera

Last edited by oombera; 02-19-2004 at 04:38 PM..
maverick
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

move files to some folder

Hello folk, I want to move some *.jpg and *.JPG to some folder but i want move from current path not from subdirectories, wants to move 200 days old file. it will go in /dir/aa/target/*.jpg|*.JPG but not go inside /dir/aa/target/other-directories, Plese help (2 Replies)
Discussion started by: learnbash
2 Replies

2. Shell Programming and Scripting

Move files & folder structure

Hey, this might be a really basic question, but I'm new to Unix scripting. I'm trying to find a command to replicate a file structure from one location to another & move the actual files contained in the base directories, i.e. I have this structure - home/temp/test/dir1/ ... (3 Replies)
Discussion started by: SOCLA_CELT
3 Replies

3. Shell Programming and Scripting

Move all files but not folders to a new folder

Hi, I have a sub directory with a number of files and folders. What i want is a subdirectory with just folders and not files for cleanliness sake. So I want to move the files into the new folder but keep the folders in the same place. Move all files (but not folders) to new folder. I am... (4 Replies)
Discussion started by: Hopper_no1
4 Replies

4. UNIX and Linux Applications

Move Files From One Folder To Another In UNIX

There are around 13 files in folder1.I need to move these files to another folder folder2,one file at a time, after checking whether a file exists in another folder folder3. If a file exists in folder3, we should not move files from folder1 to folder2. If there are no files in folder3, we need... (1 Reply)
Discussion started by: Jassz
1 Replies

5. Shell Programming and Scripting

Move only files to a folder

I want to move all the files inside a directory to another directory which is inside that directory. Please help. Note: I want to move only the files. Note the folders. Thanks in advance. (4 Replies)
Discussion started by: brnl_basu
4 Replies

6. Shell Programming and Scripting

To move multiple files to a new folder everytime

Hi , Below is the scenario A.txt B.txt C.csv .......... i want to move all the above files in to a new path & new folder .This folder is created based on date(for ex: today's fodler name will be 20120222).for Everyday move a new folder based on date has to be created & this folder... (1 Reply)
Discussion started by: jagadeeshn04
1 Replies

7. Solaris

Move files to another folder base on DU

Hi, I want to move files like *.txt to another filesystem on the same server only when the disk usage reaches 80% or more. But need to keep the latest 5 files. After that delete from the original. How to proceed? Please help Gav... (5 Replies)
Discussion started by: Gavisht
5 Replies

8. Shell Programming and Scripting

Move files from Space Folder to other folder

I want to move a folder with spaces from one folder to another. I have two folders like this, 1).RT_032-222 -4444-01/ 2). RT_032-555 -7777-01/ I want to move files from 2 to 1 through shell script.Here I want to assign this like a user defined variable like as Source branch... (2 Replies)
Discussion started by: kannansoft1985
2 Replies

9. Shell Programming and Scripting

Request for Shell script to move files from Subfolder to Parent folder and delete sub folder

Hi Team, I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder. Eg: parent folder --> /Interface/data/test/IN Sub folder -->/Interface/data/test/IN/Invoice20180607233338 Subfolder will be always with timestamp... (6 Replies)
Discussion started by: srivarun15
6 Replies

10. Shell Programming and Scripting

Move files with a certain suffix based on how many files are in another folder

Hello, First time poster. I am looking for a way to script or program the process of moving files from one folder to another, automatically, based on the count of files in the destination folder. I was thinking a shell script would work, but am open to the suggestions of the experts... (6 Replies)
Discussion started by: comtech
6 Replies
rmf(1)							      General Commands Manual							    rmf(1)

NAME
rmf - remove folder (only available within the message handling system, mh) SYNOPSIS
rmf [+folder] [-help] [-[no]interactive] OPTIONS
Prints a list of the valid options to this command. Asks for confirmation before deleting a folder. By default, rmf deletes a folder and its messages without asking for confirmation. If you specify the -interactive option, rmf asks if you are sure before deleting the folder. You are advised to use this option, since when rmf deletes a folder its contents are lost irretrievably. DESCRIPTION
The rmf command removes all of the messages within the current folder, and then removes the folder itself. If there are any files within the folder which are not part of MH, they are not removed, and an error message is displayed. You can specify a folder other than the current folder by using the +folder argument. If you do not specify a folder, and rmf cannot find the current folder,rmf asks you whether you want to delete +inbox instead. If the current folder is removed, it makes +inbox current. Note that the rmf command irreversibly deletes messages that do not have other links, so use it with caution. If the folder being removed is a sub-folder, the parent folder becomes the new current folder, and rmf tells you that this has happened. This provides an easy mechanism for selecting a set of messages, operating on the list, then removing the list and returning to the current folder from which the list was extracted. Using rmf to delete a read-only folder deletes the private sequence and current message information from the file, without affecting the folder itself. If you have sub-folders within a folder, you must delete all the sub-folders before you can delete the folder itself. PROFILE COMPONENTS
Path: To determine the user's Mail directory EXAMPLES
This example shows how rmf asks for confirmation when the -interactive option is used: % rmf -interactive +test Remove folder "test"? y FILES
The user profile. SEE ALSO
rmm(1) rmf(1)
All times are GMT -4. The time now is 06:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy