|
| |||||||||
| Tags: batch, copy file, move file, programming, rename file, shell script |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Copy, move, rename file via programming
I want to automate recurrent tasks (i.e. Copy, move, rename file) to save time. If only it were simple data processing! I do not know programming. It seems that the batch is best suited for this kind of manip. I have it yet: Code: folder xxx
/ \
folder yy folder zz
/ \ / \
folder folder folder folder
Jpeg Dng Jpeg Dng
| | | |
file file file file
jpg Dng jpg Dng Let me get this: Code: folder xxx
/ \
folder yy folder zz
| |
file file
jpg jpg I come hard to know how but I think this could work: 1. Delete all files except the file xxx. Jpg 2. Moving JPEG files in their parent folder 3. Delete empty folders |
|
#2
| |||
| |||
| Re: Copy, move, rename file via programming
to delete the file Dng Code: find folderxxx -name *.Dng - exec rm { } \; Code: for f in $ (find folderxxx -name "*.jpg" ) ; do mv $f $ ( dirname $ ( dirname $f ) ) ; done Code: find folderxxx - type d -empty - exec rmdir { } \; |
|
#3
| |||
| |||
| Re: Copy, move, rename file via programming
But I have come not to execute the batch. I just tried to launch the first but it does not work. I put it in my batch: Code: @echo off
find folderxxx -name *.dng -exec rm {} \; What I forgot? |
|
#4
| |||
| |||
| Re: Copy, move, rename file via programming
The orders I have given are unix commands, if you're on windows, recover on http://unxutils.sourceforge.net/ and then it should work (Windows has a find command that corresponds to grep unix, but not to find unix) ... |
|
#5
| |||
| |||
| Re: Copy, move, rename file via programming
Excuse me for my ignorance. But I can not. I get UnxUtils. So I must at first be able to apply the script. But how exactly. Does it need to execute a file in UnxUtils (there are many executable)? Do I have to UnxUtils in a particular folder? For the script, I created a xxx.bat? With the code you gave me, it must add a "@echo off" or something else? |
|
#6
| |||
| |||
| Re: Copy, move, rename file via programming
That may be a little complicated if you're not too comfortable with the scripts. Or when you just unzip find.exe and sed.exe, you put that part (eg d:\UnxUtils) and you call with Code: d:\unxutils\find.exe folderxxx -name *.dng | sed "s/^/ del /" Code: d:\unxutils\find.exe folderxxx -name *.dng | sed "s/^/del /" > delpng.bat delpng.bat |
|
#7
| |||
| |||
| Re: Copy, move, rename file via programming
Although old post, this is in case someone in future has the same problem. You may want to consider a biterscripting script for file manipulation like this. I wrote a quick script. Code: # Script DeleteAllButJPG.txt
# Deletes all files but .jpg files under root directory - $root.
var str root
var str list, file
lf -r -n -g "*" $root ($fype=="f") > $list
while ($list <> "")
do
# Get the next file from the list.
lex "1" $list > $file
# Does file name end in ".jpg" ?
if ( { stex -c "^.jpg^l]" $file } <> $file )
# Delete file.
system -s del "/Q" ("\""+$file+"\"")
endif
done Looks big because I added comments. |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Copy, move, rename file via programming" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How are the file management basics like copy, rename, move and delete in Windows 8? | Mr.Aiden | Operating Systems | 3 | 23-10-2011 06:17 PM |
| Need to refresh while doing Delete, Rename or Move in Windows 7 x64 | Man-Than | Windows x64 Edition | 6 | 13-05-2011 11:43 AM |
| Batch File to Move or Copy Files | Pratim | Windows Software | 6 | 21-03-2010 10:32 PM |
| Unable to rename, move or delete folder | Peter Wilkins | Windows XP Support | 15 | 01-03-2007 10:07 AM |
| Is it possible to disable "Calculating time to copy/move file..." | Baron | Vista Help | 23 | 13-01-2007 07:05 AM |