1.

Solve : how can i rename my current folder??

Answer»

thanks dear foxidrive
i think you're the only one that cares about question itself but others are all gouging

well folders are with passwords in their names and i want just 1- store those passwords in a file (password.text) in their folder and then remove password (and replace with 1 space)
so final folder's name should be something like example below
example
QUOTE

best answers(www.my-website.com)all members
should rename to
best answers all members
==========================
my_broadcasting_www.mediafree.net
should rename to
my_broadcasting
Quote from: mioo_sara on March 01, 2014, 11:04:04 PM
best answers(www.my-website.com)all members
should rename to
best answers all members
==========================
my_broadcasting_www.mediafree.net
should rename to
my_broadcasting

This makes the job more difficult as there is no well defined FORMAT for the password.Quote
This makes the job more difficult as there is no well defined format for the password.
i know at this particular time i don't need passwords i just want to remove them from folder's name

i tried script below it's working and removed www.*.com from folder's name but i should type www.*.com for every folder
i want program DETECT it automatically

Quote
for /f "tokens=* delims= " %%i in ('dir /b "*.*"') do Set LIST=%%i& set LIST | ren "%%~fi" "%%LIST:www.my-website.com= %%"

by the way i tested it on a file and not a folder

but this one works on folders very good but i want www.?.com or www.?.net detect automatically and replaced with space

EQuote
ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
FOR /D /R %%i IN (*.*) DO (
SET "n=%%~nxi"
SET n=!n:www.myp30.com= !
::SET n=!n:www.myp30.net= !
IF NOT "!n!" == "%%~nxi" MOVE "%%~i" "%%~dpi!n!"
)
The task does not have a well defined format so a general script is impossible and so it has to have an exception for every type of format that is used.

This batch file works for the two formats you have shown, and will handle www.*.com and www.*.net, and it uses the repl.bat tool by Dave Benham.

It creates the password.txt file inside the folder with the website address
- and the batch file has to be launched from the path and not located inside the folder, because doing that would lock the folder itself and the rename would fail.

If you can deal with this folder "best answers(www.my-website.com)all members"
becoming this "best answers()all members"
and this folder "my_broadcasting_www.mediafree.net"
becoming this "my_broadcasting_"
so that only the website address is removed then it could be simplified and would handle other folder-name formats.

V2.0

Code: [Select]@echo off
for %%a in ("%cd%") do set "folder=%%~nxa"
cd..
del renfolder.bat 2>nul
:: handles (www.aaa.com)
echo "%folder%"|repl ".(.*)\((www\..*?\.com)\)(.*)." ">$&\password.txt echo $2& ren $& \q$1 $3\q" axi >>renfolder.bat
:: handles (www.aaa.net)
echo "%folder%"|repl ".(.*)\((www\..*?\.net)\)(.*)." ">$&\password.txt echo $2&ren $& \q$1 $3\q" axi >>renfolder.bat
:: handles _www.aaa.com
echo "%folder%"|repl ".(.*)_(www\..*?\.com)(.*)." ">$&\password.txt echo $2&ren $& \q$1 $3\q" axi >>renfolder.bat
:: handles _www.aaa.net
echo "%folder%"|repl ".(.*)_(www\..*?\.net)(.*)." ">$&\password.txt echo $2&ren $& \q$1 $3\q" axi >>renfolder.bat
call renfolder.bat
del renfolder.bat 2>nul
pause

This uses a helper batch file called `repl.bat` - download from: https://www.dropbox.com/s/qidqwztmetbvklt/repl.bat

Place `repl.bat` in the same folder as the batch file or in a folder that is on the path.well dear foxidrive i tested your script but i wonder if it was my problem or the script but it didn't worked!
here's what i did for testing the script
1-i made a new folder named it test folder
2- inside it i made another 2 folders with website name in their names
examle
my-testing1_www.myweb.com_in test
my-testing2_www.mysite.net

3- now i copied both (repl.bat and test-batch.bat) in test folder (next to those folders)
now i tried the script test-batch.bat but nothing happened

what do you think? Quote from: mioo_sara on March 02, 2014, 01:16:24 PM
3- now i copied both (repl.bat and test-batch.bat) in test folder (next to those folders)
now i tried the script test-batch.bat but nothing happened

Perhaps I wasn't clear enough but I said this:

Quote
- and the batch file has to be launched from the path and not located inside the folder, because doing that would lock the folder itself and the rename would fail.

You must put the batch file and repl.bat in a folder on the path, such as c:\windows or c:\windows\system32

When you are at a cmd prompt inside the folder, then you type the batch-command
dear foxidrive
i tested your v2 script and i don't know why it's still not responding correctly
here's result of my test
=====================================================
1-first of all i have windows xp sp3 installed on my pc and my win-xp is in drive f:
(i don't think if it would be the reason of that)
2- in first try i copied both files(repl.bat and test-batch.bat) to f:\windows
then i clicked on f:\mytest\go.bat
(inside of go.bat there is this comment f:\windows\test-batch.bat )
nothing but a black screen that has vanished!
inside folder ( f:\mytest\ ) there are some folders that their names have website's name
i checked them but nothing has been changed! no rename and no password.txt
3- so in another test i copied both (repl.bat and test-batch.bat) to f:\windows\system32
but still nothing happened
4- in another test i tried CMD i opened CMD and typed f:\mytest\go.bat
still no successful result
=============================
now i have some questions
should i really do this process with copying some files in windows?
i mean to me it doesn't seem to be that difficult for a task like this
i think program can do some Dir find folders that their names has letters begin with (www.) and end with .com or .net and remove these letters from begin to end right?
and create a password.text in folder containing (www.....com)
You said that you wanted to do this from inside the folder. You can't click on a batch file inside the folder though because it will lock the folder and it cannot be renamed.

Just to prove it works, place the two batch files repl.bat and test-batch.bat into c:\windows and then open a cmd prompt inside the folder to be renamed.

Then type test-batch and you should see the folder renamed and a password.txt appear inside the folder.

wow ! dear foxidrive
it actually worked !! i can't even believe it !
you know if you read my first post in this topic i was looking for a way to rename my current folder but cuz it was being used by the explorer and even batch itself some guys in the forum said it's not possible . and i was disappointed so i changed my idea and tried another way(i decided to rename another folders and not current folder)
but now you proved that it's possible
thank you very very very much you solved one of my biggest problems cuz there where hundreds of folders that i wanted to be renamed but cuz my program was added to my right click menu i wanted just selected folder renamed and not all of them(that's my current folder story)
and sorry for the late answer i was out of town for a few hours
thanks again i hope you have very good year ahead for yourself and for your family
sorry to disturb you again dear foxidrive i don't know why program is not stable i mean i tried it with LOTS of other folders and although their structures where not different in names but program didn't worked anymore and i even tried to make a folder with my first test structure (first successful test) but it failed again and nothing happened
i even disabled my kaspersky antivirus but nothing changed
don't you think if it would be better to do it with DIR and if program found folder with website names ask if i want it to be renamed (yes/no)
i think copying .bat file in windows make it more unstable than before i can remove program from my right click menu (forget about current folder)and work with search and replace (yes/no)
what do you think?

now i'v found reason of the problem
problem was because of folder's name and( ) those that their names was in () just has been renamed
ok ! ok i can solve this problem dear foxidrive thanks again


Discussion

No Comment Found