David Izen
asked on
PowerShell help - comparing folder and file names
Hi All
We have a server with a file structure where each client has their own folder, and the client/folder has a unique 5-digit reference, thus a client folder might be named '12345 Mr Aardvark'. This client folder likely contains many nested sub-folders. Every file within any of these folders is supposed to be prefixed with '12345', for example '12345 Welcome Letter.docx'
I'm trying to write a PowerShell script that can live at the top level of each client folder. When run, the script generates a list of every file in either the main client folder or any of its sub-folders (I'm good to here) then compares the first 5 characters of each file name with the 5 characters of the client folder name, and generates a report listing by location those files which have either been mis-filed or more likely have been saved without the 5 character identifier. This bit I am not so good at.
In a perfect world I guess the report would be run at a set time each night and a report listing every mismatch and their location placed in a single file in the root 'Clients' folder.
Any pointers gratefully accepted and I'll happily consider this a commercial project.
Thanks for any help,
Kind regards
David
We have a server with a file structure where each client has their own folder, and the client/folder has a unique 5-digit reference, thus a client folder might be named '12345 Mr Aardvark'. This client folder likely contains many nested sub-folders. Every file within any of these folders is supposed to be prefixed with '12345', for example '12345 Welcome Letter.docx'
I'm trying to write a PowerShell script that can live at the top level of each client folder. When run, the script generates a list of every file in either the main client folder or any of its sub-folders (I'm good to here) then compares the first 5 characters of each file name with the 5 characters of the client folder name, and generates a report listing by location those files which have either been mis-filed or more likely have been saved without the 5 character identifier. This bit I am not so good at.
In a perfect world I guess the report would be run at a set time each night and a report listing every mismatch and their location placed in a single file in the root 'Clients' folder.
Any pointers gratefully accepted and I'll happily consider this a commercial project.
Thanks for any help,
Kind regards
David
ASKER
Fantastic - thank you so much! Love the fact you took the trouble to write in a check for the 5-digit folders - brilliant!
ASKER
Sorry to be a pain but trying to implement this and our setup is slightly different to what i thought
So for instance it may be something similar to;
A1234-Alice
A2345-Adam
So a letter followed by 5 numbers and not 5, and then the hyphen (-) so no spacing either
i have tried to edit the above script to accommodate this but cant quite get it working
Any suggestions?
Many thanks
So for instance it may be something similar to;
A1234-Alice
A2345-Adam
So a letter followed by 5 numbers and not 5, and then the hyphen (-) so no spacing either
i have tried to edit the above script to accommodate this but cant quite get it working
Any suggestions?
Many thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thats done it, thank you very much!
Question answered.
Open in new window