PC Review


Reply
Thread Tools Rate Thread

checking file content and move to another dir files with same content

 
 
Matthieu
Guest
Posts: n/a
 
      30th May 2005
Hello,

I have a directory with some files in it, actually .xls files.
I need to figure out if the content of thoses files is the same or not, and
if it's the same move it to an new folder.

Is it possible to script that ?
Can someone help me ?

Cheers,
MAtthieu


 
Reply With Quote
 
 
 
 
billious
Guest
Posts: n/a
 
      30th May 2005

" Matthieu" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> I have a directory with some files in it, actually .xls files.
> I need to figure out if the content of thoses files is the same or not,
> and
> if it's the same move it to an new folder.
>
> Is it possible to script that ?
> Can someone help me ?
>
> Cheers,
> MAtthieu
>
>



You'd possibly get a better response at alt.msdos.batch.nt

Meanwhile, try this - assuming that you mean "move any (.xls) files where
there is an identical (.xls) file in the directory to another directory":

--- mdf.bat begins ---

[01]@echo off
[02]:: are there any .xls files in the source directory?
[03]if not exist *.xls goto :eof
[04]:: need to establish a Temporary File
[05]set ytf=d
[06]:tfloop
[07]if exist %temp%\%ytf%* set ytf=%ytf%f&goto tfloop
[08]set ytf=%temp%\%ytf%
[09]:: find all .xls files in source directory, and their sizes
[10]for /f %%i in ('dir /b /a:-d *.xls') do echo %%~zi %%i>>%ytf%1
[11]for /f "tokens=1*" %%i in (%ytf%1) do for /f "tokens=1*" %%I in (%ytf%1)
do if %%I==%%i if not "%%J"=="%%j" set yf1=%%j&set yf2=%%J&call :movedupe
[12]:: clean up tempfile and environment variables
[13]del %ytf%*
[14]for %%i in (ytf yf1 yf2) do set %%i=
[15]goto :eof
[16]
[17]:movedupe
[18]:: file may have already been moved
[19]if not exist "%yf1%" goto :eof
[20]if not exist "%yf2%" goto :eof
[21]:: compare 2 same-size files
[22]fc /b "%yf1%" "%yf2%" >nul
[23]:: errorlevel is zero if they are identical
[24]if errorlevel 1 goto :eof
[25]if exist "\destdir\%yf2%" echo Cannot move "%yf2%"&goto :eof
[26]move "%yf2%" \destdir
[27]goto :eof

--- mdf.bat ends ---

Each line begins [number]. Lines will be wrapped in transmission and need to
be rejoined. The [number] at the beginning of each line needs to be removed.

Note the use of %%i and %%I because the process applied to each is similar.
In this case, the program IS case-sensitive.

HTH

....Bill


 
Reply With Quote
 
Mark V
Guest
Posts: n/a
 
      30th May 2005
In microsoft.public.win2000.cmdprompt.admin Matthieu wrote:

> Hello,
>
> I have a directory with some files in it, actually .xls files.
> I need to figure out if the content of thoses files is the same
> or not, and if it's the same move it to an new folder.
>
> Is it possible to script that ?
> Can someone help me ?


I suspect the first priority here is to define "content of thoses
files is the same". Exact duplicates under differing names could be
determined using fc.exe. In practice, one could have two XLS files
that contain identical visible content, yet would fail a binary
comparison because of differences to the (invisible) internal file
structure.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Detecting tsv/csv files basing on file content Yexiong Feng Microsoft C# .NET 10 17th Apr 2009 10:53 PM
Add RFT File Content and Page Break and then Content of other textbox sivachitra81@gmail.com Microsoft Dot NET 0 23rd Feb 2007 12:46 PM
error: Only Content controls are allowed directly in a content page that contains Content controls. hazz Microsoft ASP .NET 2 27th Apr 2006 06:32 PM
Search files and folders not searching content of files (file compression wasn't the problem) Mike Ditka Windows XP General 2 18th May 2005 03:47 PM
Extract content files from CAB file =?Utf-8?B?TGVzbGllIEtvdQ==?= Microsoft Dot NET Framework 0 19th Apr 2005 09:04 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:18 PM.