Batch script

Closed
guru - May 30, 2010 at 01:44 AM
Richard.Williams Posts 25 Registration date Saturday November 7, 2009 Status Member Last seen July 18, 2012 - Jun 13, 2010 at 01:21 PM
Hello,

Urgently i need a batch script to get similar filenames(in a textfile) with path from two different folders.Can anyone help me pls...

I found few commands to get a filename from a folder and list in a textfile with path - DIR "G:\automation_stuffs\10.4.0" /B/S/A:-D>list76.txt

in above G:\automation_stuffs\10.4.0 is a folder path

and another command to list filename alone from a folder - for /r G:\automation_stuffs\10.4.0 %%g in (*) do echo %%~nxg>>list1.txt

Kindly help me..very very urgent..



3 responses

Richard.Williams Posts 25 Registration date Saturday November 7, 2009 Status Member Last seen July 18, 2012 14
Jun 13, 2010 at 01:21 PM
Use this script. (It will handle file names with spaces and other special characters.)

# Script DetectDuplicate.txt
var string folder1, folder2
var string list1, list2, path2, file2
lf -n "*" $folder1 ($ftype=="f") > $list1
lf -n "*" $folder2 ($ftype=="f") > $list2
while ($list2 <> "")
do
    lex "1" $list2 > $path2
    stex "^/^l[" $path2 > $file2
    if ( { sen ("^"+$file2+"^") $list1 } > 0 )
        # Duplicate file - report to user.
        echo $folder1 "/" $file2 "\n" $folder2 "/" $file2
    endif
done




Script is in biterscripting. Save the script in file C:/Scripts/DetectDuplicate.txt, start biterscripting, enter this command.


script "C:/Scripts/DetectDuplicate.txt" folder1("D/folder1") folder2("D:/folder2")



It will report duplicate files in folders D:/folder1 and D:/folder2.
1
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
May 31, 2010 at 01:26 PM
what you mean by "similar "
0
similar means same filenames.

I need filenames of same name from two different folders.This filenames should need on a textfile with exact path.And one more requirement is , i need filenames in following format -

For example - folder 1 has two files (file1,file2) in D ridve and folder2 has four files (file0,file1,file2,file3).in D drive.

The output should be as below on seraching file1 and file 2 in folder 1 and folder2 -

D:/folder1/file1
D:/folder2/file1
D:/folder1/file2
D:/folder2/file2
0
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Jun 1, 2010 at 08:00 AM
Does every thing has to be done in DOS script or can you import the dir listing of the two folders in an excel file and then separate out common files ?
0
gurusamy Posts 1 Registration date Thursday June 3, 2010 Status Member Last seen June 3, 2010
Jun 3, 2010 at 09:55 AM
ANything is fine for me.I need seperate common files in a textfile.Another additional requirement - even need different files listing of two folders.
0
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Jun 3, 2010 at 11:01 AM
Could you please upload a a zip file with two directory listing on some shared site like https://authentification.site , http://wikisend.com/ etc and post back here the link to allow better understanding
0