View unanswered posts | View active topics It is currently 01 Nov 2014 03:31



Post new topic Reply to topic  [ 12 posts ] 
script to separation of data according to picture number 
Author Message

Joined: 25 Apr 2012 04:28
Posts: 66
Post script to separation of data according to picture number
Hi
I need a script that will help me copy gif files from one folder to another according to picture number.
I have a single folder containing ~200,000 files including many ubc images.
The filename of the images is built like this:
WeInput_du185_wu.110.303.3.1_picture340_frame303_ref303_Det_InImage1.gif
Manual Input: slice number, source folder, destination folder (I can change the input in text editor, or any other way you specify).
I wrote this script
@echo off
set /p file="Enter search cretiria:"
set /p source="Enter Source folder (c:\folder name):"
set /p dest=" Enter destnation folder (c:\folder name:)"
forfiles /p %source% /m *%file%*.gif /c "cmd /c copy @file %dest%"

It's work find on Win7
but not working in XP
any suggestion or alternative ?
(I try to dowwnload from http://www.petri.co.il/download_free_reskit_tools.htm but it's doest work good..)


25 Apr 2012 04:36
Profile

Joined: 23 Dec 2011 13:59
Posts: 1952
Post Re: script to separation of data according to picture number
mor.bas wrote:
It's work find on Win7
but not working in XP
any suggestion or alternative ?
(I try to dowwnload from http://www.petri.co.il/download_free_reskit_tools.htm but it's doest work good..)

That's because that link is for the Windows 2000 resource tools. Forfiles had a different syntax in Windows 2000. You need to download Forfiles that come with Windows 2003.


25 Apr 2012 05:42
Profile

Joined: 25 Apr 2012 04:28
Posts: 66
Post Re: script to separation of data according to picture number
Hi
From where I get 2003 ver?
or
Can you post another alternative script that I don't need to copy this file to sys32 and it will work fine also in XP.


25 Apr 2012 06:08
Profile

Joined: 10 Feb 2012 02:20
Posts: 4331
Post Re: script to separation of data according to picture number
Try this on some sample files and folders (untested):

Code:
@echo off
:loop
set /p "file=Enter gif file search criteria:"
if not exist "%source%\*%file%*.gif" echo filespec doesn't exist error - try again &goto :loop
set /p "source=Enter Source folder (c:\folder name):"
if not exist "%source%\" echo source doesn't exist error - try again &goto :loop
set /p "dest=Enter destination folder (c:\folder name:)"
if not exist "%dest%\" echo destination doesn't exist error - try again &goto :loop

for /f "delims=" %%a in ('dir "%source%\*%file%*.gif" /b /a-d') do (
echo copying "%source%\%%a"
copy /b /y "%source%\%%a" "%dest%" >nul
)
echo done
pause


25 Apr 2012 08:23
Profile

Joined: 25 Apr 2012 04:28
Posts: 66
Post Re: script to separation of data according to picture number
Hi
thanks nice script
but I have question to understand it good..
1. why you need dir /b /a-d?
(/b give you the bare files and its quite good)
2.why you need copy /b /y
/b for binary?
/y - why exacly?


26 Apr 2012 08:48
Profile

Joined: 10 Feb 2012 02:20
Posts: 4331
Post Re: script to separation of data according to picture number
/a-d stops any folder that might match the filespec from causing errors. It's possible, as folders can have extensions.

/b /y allows the batch file to overwrite existing files, to stop the batch file from halting if files already exist. /b is for a binary copy.


26 Apr 2012 10:01
Profile

Joined: 08 Apr 2012 17:11
Posts: 187
Post Re: script to separation of data according to picture number
mor.bas wrote:
(...)
1. why you need dir /b /a-d?
(...)
2.why you need copy /b /y
(...)
/y - why exacly?


The /a-d switch will show you everything in the directory but the directories themselves.
And the /y switch stands for yes; it will suppress any "overwrite file?" prompt.


26 Apr 2012 10:10
Profile WWW

Joined: 25 Apr 2012 04:28
Posts: 66
Post Re: script to separation of data according to picture number
Hi
Can you explain why or what is binary copy?


26 Apr 2012 23:14
Profile

Joined: 08 Apr 2012 17:11
Posts: 187
Post Re: script to separation of data according to picture number
mor.bas wrote:
Hi
Can you explain why or what is binary copy?


Wikipedia wrote:
A binary file is a computer file which may contain any type of data, encoded in binary form for computer storage and processing purposes; for example, computer document files containing formatted text. Many binary file formats contain parts that can be interpreted as text; binary files that contain only textual data—without, for example, any formatting information—are called plain text files. In many cases, plain text files are considered to be different from binary files because binary files are made up of more than just plain text.

This is the definition of binary file. COPY command needs /binary copying because of these binary files.


27 Apr 2012 06:08
Profile WWW

Joined: 10 Feb 2012 02:20
Posts: 4331
Post Re: script to separation of data according to picture number
The reason why you need /b is that in past versions of Microsoft OS the copy command stops copying when it encounters an EOF byte/character, and many non-text files contain these bytes.

These days I think the copy command has been enhanced and it will automatically switch to binary copy mode on some filetypes - but probably not all. It's still prudent to use /b to be sure.

The amusing thing is that it is safe to use /b even on text files so there is no reason not to use it all of the time

(except when concatenating several text files in this format)

copy file1.txt + file2.txt + file3.txt fileout


27 Apr 2012 06:19
Profile

Joined: 23 Dec 2011 13:59
Posts: 1952
Post Re: script to separation of data according to picture number
foxidrive wrote:
The amusing thing is that it is safe to use /b even on text files so there is no reason not to use it all of the time

(except when concatenating several text files in this format)

copy file1.txt + file2.txt + file3.txt fileout


I use /B even in that instance. The reason being is because it will put an EOF character at the end of the combined file if you don't.


27 Apr 2012 06:24
Profile

Joined: 10 Feb 2012 02:20
Posts: 4331
Post Re: script to separation of data according to picture number
The problem is that with /b in this way it can embed EOF characters within the text file - if the text files have them.


27 Apr 2012 06:27
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 


Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Yahoo [Bot] and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by Vjacheslav Trushkin for Free Forums/DivisionCore.