Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

How can you make a file name comparison

$
0
0

Hello, I'm making a program that would do the following:

1.) Collect the names of folders (3 letter name)

2.) See if there's any name of files that contains this format "ABC_"

3.) If it does then put that file in that folder.

I know i might need a loop to look for it one by one and compare it, but i was wondering if there's another way then the way i was doing it.

Here's my code:

$year = "2013"
$Names= Get-ChildItem \\Server\Drive\Folder | Foreach-Object {$_.name} 
$ABC = $Names
$User1= Get-ChildItem "\\Server\Drive\username\scans\"+$ABC+"_*"
$User2= Get-ChildItem "\\Server\Drive\username\scans\"+$ABC+"_*"
$User3= Get-ChildItem "\\Server\Drive\username\scans\"+$ABC+"_*"
$User4= Get-ChildItem "\\Server\Drive\username\scans\"+$ABC+"_*"

if ($ABC-eq $Names){
Move-Item 
"\\Server\Drive\username\scans\"+$ABC+"_*" 
"\\Server\Drive\Folder" + $Names+ "\Folder\" +$year +"\"
}




Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>