You are not logged in.

#1 29 Oct 2015 20:51

Linkso
Member
Registered: 29 Oct 2015
Posts: 2

Help with a program that changes files names and moves said files

Hello eveyone, I been having some issues trying to make a .bat that would change the name of some files and its location.
I'll begin with the reason why I need said bat. (If you know of any program that can do what i need that's is also fine for me)
In my computer I found some photos that I have but they are a mess. They are in a folder and in said folder there are like 1000 different folders named from 234 to 1012 and in every folder there is usually only one photo called cap00xxx.bmp (x being numbers from 0 to 9) sometimes there are from 2 to 5 different photos in th same folder. The issue is that the name of the files is the same from folder to folder. For example: in folder 234 I have a photo called cap00001.bmp and in the folder 235 I have a different photo called cap00001.bmp and so on. So I decided to make a bat that would enter every folder and change the name of every and move said file to a folder, so that way I would have all my photos organized in one folder.
I already made the code but im not sure if I got something wrong because the bat closes telling me that it cant find a file, here is the part im having issues with.
Thanks everyone.

 
:while1
	if %x% leq 1000 (
		cd %a%
			:while2
				if %y% leq 100(
				rename cap0000%y%.bmp %b%.bmp 
				rename cap0000%y%.bmp %b%.bmp
				rename cap0000%y%.bmp %b%.bmp
				rename cap000%y%.bmp %b%.bmp 
				rename cap000%y%.bmp %b%.bmp
				rename cap000%y%.bmp %b%.bmp
				rename cap00%y%.bmp %b%.bmp 
				rename cap00%y%.bmp %b%.bmp
				rename cap00%y%.bmp %b%.bmp
				Move (File path)\%a%\%b%.bmp (Path I want)
				set /a "y = y + 1"
				set /a "b = b + 1"
				pause
				goto :while2
						)
		cd..
		set /a "x = x + 1"
                set /a "a = a + 1"
		goto :while1
			)

Offline

#2 30 Oct 2015 03:20

Shadow Thief
Member
Registered: 12 Jul 2012
Posts: 205

Re: Help with a program that changes files names and moves said files

Where are you getting your %a% and %b% variables? We can't help unless you show us the entire code, or at least a chunk of code that actually works by itself.

Offline

#3 30 Oct 2015 06:16

Linkso
Member
Registered: 29 Oct 2015
Posts: 2

Re: Help with a program that changes files names and moves said files

I couldnt find a way to edit my post so im going to post the full code here.

@echo off
set /a "x = 0"
set /a "y = 0"
set /a "a = 234"
set /a "b = 0"
echo %x%
echo %y%
echo %a%
echo %b%
pause
:while9
	if %x% leq 100 (
		echo %x%
		set /a "x = x + 1"
			:while99
				if %y% leq 5 (
					echo Test%y%
					set /a "y = y + 1"
					goto :while99
						)
set /a "y = 0"
goto :while9
	)
set /a "x = 0"
set /a "y = 0"
echo %x%
echo %y%
echo %a%
echo %b%
pause
:while1
	if %x% leq 1000 (
		cd %a%
			:while2
				if %y% leq 100(
				rename cap0000%y%.bmp %b%.bmp 
				rename cap0000%y%.bmp %b%.bmp
				rename cap0000%y%.bmp %b%.bmp
				rename cap000%y%.bmp %b%.bmp 
				rename cap000%y%.bmp %b%.bmp
				rename cap000%y%.bmp %b%.bmp
				rename cap00%y%.bmp %b%.bmp 
				rename cap00%y%.bmp %b%.bmp
				rename cap00%y%.bmp %b%.bmp
				Move (File path)\%a%\%b%.bmp (Path I want)
				set /a "y = y + 1"
				set /a "b = b + 1"
				pause
				goto :while2
						)
		cd..
		set /a "x = x + 1"
		set /a "a = a + 1"
		goto :while1
			)
pause
end

Offline

#4 30 Oct 2015 15:01

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: Help with a program that changes files names and moves said files

If you had described the target filename format it would have been easier to understand what you need.

You can test this on a sample folder called "d:\My pictures\folder" to see how it works - and create d:\newfolder for the saved files.

@echo off
for /r "d:\My pictures\folder" %%a in (*) do (call move "%%a" "d:\newfolder\%%random%%%%random%%%%random%%%%random%%%%random%%%%random%%%%random%%%%random%%%%random%%%%random%%%%random%%%%~xa")

Last edited by foxidrive (30 Oct 2015 15:05)

Offline

Board footer

Powered by