Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 1.76 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to rename and move files to new directory
  2. FOR  /R C:your_folder %%d  IN  (*.txt)  DO  (
  3.     ren %%d %%~nd.txt_mvd
  4. )
  5.        
  6. FOR  /R E:your_folder %%d  IN  (*.*)  DO  (
  7.     IF %%~dpd==E:your_folder (
  8.         ren %%d %%~nd.txt_mvd
  9.     )
  10. )
  11.        
  12. FOR  /R E:your_folder %%d  IN  (*.txt)  DO  (
  13.     IF %%~dpd==E:your_folder (
  14.         ren %%d %%~nd.txt_mvd
  15.     )
  16. )
  17.        
  18. set Extension_of_file_you_want_to_renamne_and_move=txt
  19. set New_extension_of_moved_files=txt_mvd
  20.  
  21. set Folder_that_contain_your_files=C:Your_starting_folder
  22. set Folder_where_to_move_your_files=C:Your_destnation_folder
  23.  
  24. FOR  /R %Folder_that_contain_your_files% %%d  IN  (*.%Extension_of_file_you_want_to_renamne_and_move%)  DO  (
  25.     IF %%~dpd==%Folder_that_contain_your_files% (
  26.     IF %%~xd==.%Extension_of_file_you_want_to_renamne_and_move% (
  27.         ren "%%~d" "%%~nd.%New_extension_of_moved_files%"
  28.         move "%%~dpnd.%New_extension_of_moved_files%" "%Folder_where_to_move_your_files%"
  29.         )
  30.     )
  31. )
  32.        
  33. set Folder_that_contain_your_files = c:myFolder      <--- WRONG, WON'T WORK, there are unneeded space
  34.        
  35. set Folder_that_contain_your_files=c:myFolder      <--- OK, THIS WILL WORK, there are no extra spaces
  36.        
  37. set Extension_of_file_you_want_to_renamne_and_move=txt
  38. set New_extension_of_moved_files=txt_mvd
  39.  
  40. set Folder_that_contain_your_files=C:Your_starting_folder
  41. set Folder_where_to_move_your_files=C:Your_destnation_folder
  42.  
  43. FOR  /R "%Folder_that_contain_your_files%" %%d  IN  (*.%Extension_of_file_you_want_to_renamne_and_move%)  DO  (
  44.     IF "%%~dpd"=="%Folder_that_contain_your_files%" (
  45.     IF %%~xd==.%Extension_of_file_you_want_to_renamne_and_move% (
  46.         ren "%%~d" "%%~nd.%New_extension_of_moved_files%"
  47.         move "%%~dpnd.%New_extension_of_moved_files%" "%Folder_where_to_move_your_files%"
  48.         )
  49.     )
  50. )