1

So I feel like PS would be the best solution for this project, but cannot for the life of me figure out where to get started with it, here's the file layout..

I've got one folder, filled with folders generated by our automated system, they are labeled: foobarXXXXXXXXXXXXXXX The end 15 characters of the folder is what I need to grab, and then search through another folder for any files that contain those 15 characters, and then move any files found into their respective folders.

I can give more details if this wasn't sufficient. Just need a point to get started.

I'm running Windows 7 should the version of PowerShell be a concern.

2
  • I understand the need for "general help". My big complaint with StackExchange is that they are so afraid of doing people's homework, they do not allow questions like this. I too sometimes have the need for "general help" on a subject, but it gets confused with trolling. Anyways, glad I can help point you in the right direction. I think this website needs more of this type of help. Thanks. Commented Dec 3, 2012 at 22:40
  • Yeah, not homework, just work, lol. At least I get paid for it though. Commented Dec 3, 2012 at 23:46

1 Answer 1

3

Ideally you want Powershell 3, but you can accomplish this task in Powershell 2 as well.

I would first look into the Select-String cmdlet. Also found on technet here.

It is also perfectly legal to use SubString function for .NET string manipulation.

$filePattern = $string.Substring(1,15)

To get collections of your files, you should use Get-ChildItem. Using the "@" in "@(Get-ChildItem)" produces an explicit array.

$files = @(Get-ChildItem -Path $path -Recurse)

And since there is no specific detail in your question there are no specific answers.

Also, I run Windows 7 with Powershell 2 and 3, side by side. Powershell 3 is kinda awesome.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.