Jump to content
Covecube Inc.
  • 0
JasonC

Strange behavior changing many file names at once causing problems?

Question

I have a tiny powershell script I'm using to replace square brackets with parenthesis on folder names(it seems that while you can do them, square brackets are technically not supposed to be in file/folder names in NTFS anymore). Anyway, I've noticed when I run this guy, it seems like at first, it will be humming along smoothly, and then after some point, I start getting IOException errors that items are in use by another process. I've looked extensively, and I can't find anything holding a lock though. This happens regardless if it's a network share or local to the pool(I'm usually starting on a network share).

What's more odd, it seems like the change actually does go through.  Regardless, it was a little bit disconcerting, I thought I'd see if this is a DrivePool thing or what. I've never run into anything like it with just a more typical ntfs setup.

the error is I start getting is:

Quote

Move-Item : The process cannot access the file because it is being used by another process.

Or more specifically:

Quote

    + FullyQualifiedErrorId : MoveDirectoryItemIOError,Microsoft.PowerShell.Commands.MoveItemCommand

 

The most recent run I did was about 200 foldes, so it doesn't even seem like that much load. Is this DrivePool causing this, do you think?

Thanks!

 

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0

I'm totally throwing out a couple of SWAGs here, but my first guess is that somehow Drivepool's command queue may be getting swamped.

What DP has to do when you rename a folder:

  • Check all drives in the pool for the existence of the folder, if you have file/folder or pool duplication going on
  • Rename each existence if it found one

The way to check and see if Drivepool is the culprit is to run it against the actual volume, not the pool itself.  i.e. if your pool letter is D: and it has E: and F: in it, run the utility against both E: and F:.  That takes Drivepool out of the equation, though you'll want to do a re-measure on the pool after (in case any of those you renamed were duplicated) so it can adjust.  I believe DP keeps duplication info in the pool itself.  If the utility ended up renaming folders that explicitly had duplication set in DP, then you'd have to go and add them again.

The other possibility is that some process(es) still have handles open to those folders or files under them.  If you rebooted into Safe Mode and ran the utility against the drives (E: and F: respectively), you might be able to get around those processes that lock you out of the change.  It would be worth testing.

Share this post


Link to post
Share on other sites
  • 0

Question if you are renaming directories why are you using Move-Item?

Rename-item would be what i would use.

From a Dp perspective - does a balance begin after the script starts to run - which may be causing an issue if the directories being renamed are subdirectories of another which has also been renamed.

Share this post


Link to post
Share on other sites
  • 0
11 minutes ago, Spider99 said:

Question if you are renaming directories why are you using Move-Item?

Didn't occur to me to switch it. I went with that little used "reuse code" strategy pulling some code that I wrote for a related process that moves files while renaming them. This guy actually feeds the file mover, the square brackets were causing my Powershell script to choke though. 

So, it just occurred to me as I was logging into the forum and saw the other thread, the Windows search indexer could be the problem. I'll have to try suspending the Search Indexer and then running the operation.

 

Share this post


Link to post
Share on other sites
  • 0

I can go ahead and collect some logs. I'm pretty sure I can make it happen on demand. This is actually the second or third time I've seen it. I first saw it last week, which was when I first tried running my scripts. I'll can generate a test setup and run my script against it. It could very well be too what Spider99 pointed out, I don't know if Move-Item has more overhead that would be avoided if I was calling Rename-Item instead. It was sort of a mental map failing from *nix days where you just used mv to rename things.

 

Share this post


Link to post
Share on other sites
  • 0
On 9/19/2018 at 9:03 AM, Spider99 said:

Rename-item would be what i would use.

I tried switching...it seems that Rename-Item is much less capable in handling the square brackets then Move-Item is. I get errors I don't get when moving the file to a new name.

 

On 9/19/2018 at 3:29 PM, Christopher (Drashna) said:

If the issue continues, then could you enable logging?

I think I found my problem. It also turns out the Move-Item doesn't like it very much if you throw it a rename command with replace that doesn't meet the replace criteria. It appears that if Get-ChildItem passes such an item, it throws an error as though the file were locked, like it thinks that's the reason it can't successfully rename. Anyway, looks like it may have been a bit of a red herring.

Thanks!

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...