• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 167
  • Last Modified:

Searching shared folder on network storage for duplicate files and or folder names

Looking for a quick way either by script or batch file, that can return it back to me in a text file or a readable format to look for duplicate files. Trying to clean up our shared network folders on 3 different networks.  We have im sure several programs in general, taking up a lot of space that can be cleaned up.  
0
cgooden01
Asked:
cgooden01
  • 4
  • 3
1 Solution
 
käµfm³d 👽Commented:
What is your criteria for a duplicate file (e.g. filename only)?
0
 
cgooden01Author Commented:
Criteria, would be for program files, So file name only. Or duplicate folder names as well.
0
 
cgooden01Author Commented:
We have several copies of say Roxio Install, Service Packs, Firefox, java, etc, across our network drive. Using a freeware of commercial tool, wouldnt be an option, due to the fact its on a secure, unaccessible outside network.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
käµfm³d 👽Commented:
You wouldn't by chance have the .NET framework installed on the machine that will be running the script? I ask because I would still provide you with a script, but I wanted to use some of the objects .NET provides. If not, it no biggie--I'll just work around it :)
0
 
cgooden01Author Commented:
No..dont have .NET framework running...if you could provide the script, that would be just fine.  Thanks
0
 
käµfm³d 👽Commented:
Okay. Sorry for the delay. I've attached a script which I tested locally and seems to work ok. I do not have access to a network drive right now to test in that manner, but I believe a UNC path or mapped drive can be substituted into the script without issue.

Two variables are declared at the top of the script--BASE and OUTPUT. Base will be the parent folder/drive where the folders to be searched are located. Output will be the location of the text file to write. The output file will be created if it does not exist already. If it does exist, then it will be appended to.

Because I am using recursion to search the folders, there is a chance you could get an out of memory exception--I do not know how deep your directory tree is. Also, depending on how expansive the tree is, the search could be relatively slow since each file that is not in the array is added (and each time the array is added to, it is expanded).
'''''''''''''''''''''''''''''''''''''''''''''''''''''
''    MAIN
'''''''''''''''''''''''''''''''''''''''''''''''''''''
BASE = "C:\Some\Parent\DirecTOry"					' Parent folder/drive of folders to search
OUTPUT = "C:\Some\log\direcTOry\outputfile.txt"		' Path & filename of output file
 
REDIM list(0)
 
SET fso = CreateObject("Scripting.FileSystemObject")
SET writer = fso.OpenTextFile(OUTPUT, 8, TRUE)
 
Recurse BASE
writer.Close
 
SET fso = NOTHING
SET writer = NOTHING
 
MsgBox "DONE"
 
'''''''''''''''''''''''''''''''''''''''''''''''''''''
''    FUNCTIONS
'''''''''''''''''''''''''''''''''''''''''''''''''''''
 
FUNCTION Recurse(path)
	DIM folders
 
	SET parent = fso.GetFolder(path)
	SET folders = parent.SubFolders
	SET files = parent.Files
 
	FOR Each file In files
		call CheckFiles(file)
	Next
 
	FOR Each folder in folders
		call Recurse(folder)
	Next
	
	SET parent = NOTHING
	SET folders = NOTHING
	SET files = NOTHING
 
END FUNCTION
 
FUNCTION CheckFiles(file)
	DIM found
	
	found = FALSE
	
	IF UBOUND(list) > 0 THEN
		FOR x = 0 TO UBOUND(list)
			IF list(x) = file.name THEN
				found = TRUE
				EXIT FOR
			END IF
		Next
 
		IF found THEN
			writer.WriteLine(file.Path)
		Else
			list(UBOUND(list)) = file.Name
			REDIM preserve list(UBOUND(list) + 1)
		END IF
	Else
		REDIM list(1)
		list(0) = file.Name
	END IF
END FUNCTION

Open in new window

0
 
cgooden01Author Commented:
Script did what i needed it to do. Thanks for the quick response and solution.  
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now