title: Remove hyphens and underscores from image files within a windows network share folder
body: <p>As a part of my job I frequently receive large numbers of image files that contain hyphens or underscores which need to be removed.</p>
  
  <p>I have tried using the below code, and it worked when I ran it within a folder on my dropdox. However, I tried running it on a folder in our network share, and it is not working properly. It looks like it is stripping the characters from a few of the files, and then delivering the message "A duplicate file name exists, or the file cannot be found."</p>
  
  <p>Running the file again strips the characters from a few more files before delivering the same message.</p>
  
  <pre><code>@echo off
  pushd %~dp0
  setlocal enabledelayedexpansion
  for %%j in (*.*) do (
  set filename=%%~nj
  set filename=!filename:_=!
  set filename=!filename:-=!
  if not "!filename!"=="%%~nj" ren "%%j" "!filename!%%~xj"
  )
  </code></pre>