Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: replace characters "_ " and " . " in file names to space with a batch file  (Read 58258 times)

0 Members and 1 Guest are viewing this topic.

mioo_sara

    Topic Starter


    Intermediate

    Quote
    just change "*.rar" to "*" for all files.

    what about file name dear gh0std0g74? how can  i  replace windows media player in  your script?

    i mixed  yours scriptes (Reno --gh0std0g74--devcom)  and made a wonderful program  but still  i am  not satisfied but i think  i should search  more and  more to  turn into  a more experienced programmer
    thanks again  for your cooperation

    and reno  your program  will  always remove "." from files names even  version exapmle nero v2.12

    Reno



      Hopeful
    • Thanked: 32
      and reno  your program  will  always remove "." from files names even  version exapmle nero v2.12

      because it only detect '_v'
      try this, it will detect 'v[0-9]', i couldnt' find a way to hack a for loop to work with 'set &' trick. and findstr/o doesnt display the offset as intended, so this is the manual way.
      Code: [Select]
      @echo off & setlocal

      for /r %%a in (*.rar) do call:strip "%%a"
      goto:eof

      :strip
      set app=%~n1&set ver=
      set app=%app:v0=&set ver=v0%
      set app=%app:v1=&set ver=v1%
      set app=%app:v2=&set ver=v2%
      set app=%app:v3=&set ver=v3%
      set app=%app:v4=&set ver=v4%
      set app=%app:v5=&set ver=v5%
      set app=%app:v6=&set ver=v6%
      set app=%app:v7=&set ver=v7%
      set app=%app:v8=&set ver=v8%
      set app=%app:v9=&set ver=v9%
      set app=%app:.= %
      set app=%app:_= %
      set pad=%app%                           
      echo Renaming App : %pad:~,25% Ver : %ver%
      ren "%~1" "%app%%ver%%~x1"

      mioo_sara

        Topic Starter


        Intermediate

        thanks  dear reno 100% done !!! :) :)
        wonderful  what a beautiful algorithm !! thanks man
        it can  detect "_" and "." all  over the file names and remains version  and extention
        just for a final  request can  you  put folders and subfolders in your program?
        it just now check and rename files
        thanks

        Reno



          Hopeful
        • Thanked: 32
          the following will rename files and folders that contain "v[0-9]" in its name. it wont work if name contains '=' sign.
          Code: [Select]
          @echo off & setlocal

          for /r /d %%a in (*) do call:strip "%%a"
          for /r %%a in (*) do call:strip "%%a"
          goto:eof

          :strip
          set app=%~n1&set ver=
          set app=%app:v0=&set ver=v0%
          set app=%app:v1=&set ver=v1%
          set app=%app:v2=&set ver=v2%
          set app=%app:v3=&set ver=v3%
          set app=%app:v4=&set ver=v4%
          set app=%app:v5=&set ver=v5%
          set app=%app:v6=&set ver=v6%
          set app=%app:v7=&set ver=v7%
          set app=%app:v8=&set ver=v8%
          set app=%app:v9=&set ver=v9%
          set app=%app:.= %
          set app=%app:_= %
          if /i "%~nx1" neq "%app%%ver%%~x1" (
          set pad=%app%                           
          echo Renaming App : %pad:~,25% Ver : %ver% Ext : %~x1
          ren "%~1" "%app%%ver%%~x1"
          )

          mioo_sara

            Topic Starter


            Intermediate

            thanks dear RENO :P
            folders and files are ok  now thanks for your cooperation
            have a nice and good day :)

            sepgit

            • Guest
            Re: replace characters "_ " and " . " in file names to space with a batch file
            « Reply #35 on: September 09, 2009, 10:10:48 PM »
            Hello I need some help,
            I want to replace letter # with R in evry folder and every file.eg.4676867#565:4676867R565
            please help me as soon as posible