Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Script wriring help (Attn: Pyprohly)

23 May 2015   #1
PepFontana

Windows 7 Pro 64bit
 
 
Script wriring help (Attn: Pyprohly)

Hello,

I found the below script on this very website (Folders & Shortcuts Losing Custom Icons On Removable Flash Drive) written by user Pyprohly. I am in the exact same situation as the person that originally posted, however there is one small piece of it that I am having trouble with.


I have a portable hard drive with a bunch of video files on it. When I create custom folder icons for each video, they are fine until I take the hard drive to a different PC and plug it in. Thru the above mentioned thread, I was able to determine that the problem was with the desktop.ini file listing the drive letter in the path to the icon file. If you edit the desktop.ini file and remove (In my case) the I: part of the path, it no longer matters what drive letter the various PC's assign and the icon files work as I want them to.

The problem I am having is that when I use the script in the above thread the script works perfectly if you have the files_named_like_this. If you have the file named without the underscores say for example "Jims Hockey Game" the script appears to be only using the last word in the title when it tries to write the file back into the folder. The script fails saying that the path was not found (in this example it would show that it was looking for the “I:\Game” path). This error happens to every folder that has a title with spaces in it. If the folder happens to only have a single word in the title, the script works fine and renames the .ini file.

Would someone happen to know how to edit this script to have it work correctly with files that have spaces between the words in the folder title?


I have attached a picture of what the error looks like when I run the script and I also have attached the script that is in the above link.


Thank you for any help that can be provided.




Attached Images
Script wriring help (Attn: Pyprohly)-example.jpg 
Attached Files
File Type: bat ScriptFile.bat (1.3 KB, 3 views)
My System SpecsSystem Spec
.
23 May 2015   #2
Ztruker

Windows 10 Pro X64
 
 

Try sending Pyprohly a PM (Private Message).

Edit: I see you are a new user so you will not be able to send a PM yet. I sent one for you.
My System SpecsSystem Spec
23 May 2015   #3
PepFontana

Windows 7 Pro 64bit
 
 

LOL, thanks. I searched for 15 minutes last night looking for the PM feature. I thought I was going crazy.

Thank you for forwarding that for me.
My System SpecsSystem Spec
.

24 May 2015   #4
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

Hey, sorry for any delay,

Thank you, PepFontana, for raising the error to my attention. That thread you mention, I think, was probably the third or so thread I ever assisted to here at Seven Forums. So I wouldn't be surprised if that batch script is riddled with other kinds of issues.


I rewrote a new batch script, from ground up, which may help you with your issue, PepFontana.



Find_And_Replace_Text.bat
Code:
@echo off
setlocal EnableDelayedExpansion

::
set find="F:"
set replace=""
set case_sensitive=TRUE
set line_must_start_with="IconResource",
::
set filemasks="desktop.ini",
set recurse=TRUE
set write_attributes=TRUE
::

pushd "%~dp0"& echo.
set tempfile="%TEMP%\tmp%RANDOM%_%~nx0.txt"
if /i %RECURSE%==TRUE set recurse_=/s
if /i %CASE_SENSITIVE%==TRUE ( set case_sensitive_=) else ( set case_sensitive_=/i)
if /i %WRITE_ATTRIBUTES%==TRUE ( set write_attributes_=) else ( set write_attributes_=REM )
for /f "delims=" %%I in (' dir /a:-d /b %RECURSE_% %FILEMASKS% ') do (
	set/p=Processing "%%~fI"... <NUL
	%WRITE_ATTRIBUTES_% attrib "%%~fI" -r -s -h
	copy NUL "%TEMPFILE:"=%" /y >NUL
	for /f "tokens=1,* delims=]" %%L in (' find /n /v "" ^< "%%~fI" ') do (
		if not "%%~M"=="" for %%P in ( %LINE_MUST_START_WITH% ) do (
			set line=%%M& echo.%%M| findstr /i "^%%~P" >NUL && (
				if /i %CASE_SENSITIVE%==TRUE (
					echo.%%M| findstr "%FIND:"=%" >NUL && (
						set line=!LINE:%FIND:"=%=%REPLACE:"=%!
					)
				) else ( set line=!LINE:%FIND:"=%=%REPLACE:"=%!)
			)
		) else ( set line=)
		echo.!LINE!>>"%TEMPFILE:"=%"
	)
	copy "%TEMPFILE:"=%" "%%~fI" /y >NUL
	%WRITE_ATTRIBUTES_% attrib "%%~fI" +s +h
	del "%TEMPFILE:"=%" /f /q
	echo Done.
)
echo.& echo Complete.
popd


Attached Files
File Type: bat Find_And_Replace_Text.bat (1.3 KB, 5 views)
My System SpecsSystem Spec
24 May 2015   #5
PepFontana

Windows 7 Pro 64bit
 
 

Outstanding!! It works perfectly.

Thank you so, so much.
My System SpecsSystem Spec
Reply

 Script wriring help (Attn: Pyprohly)




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
Dos script help
Hi, Below is my folder path, D:/Sample I have .sql files in that folder and i need to get the file names based on modified/created date i pass. for ex : i need to get the file names created/modified on or after 10/01/2014(mm/dd/yyyy). Can any please give me some sample script to make this...
General Discussion
Win Update Errors (attn Dude)
Dude and or others, thanks in advance for your help with this. I've updated my configuration on this site. I attached an image with most of the errors on the updates. I'm also getting a flashing dark (not black, just darker than normal) screen on my machine. I can't find anything that may be...
Installation & Setup
Attn: Security News Forum
Hi Sevenforums members. We have a new sub forum for Security News related threads. Please post any security news threads you have in this forum instead of the regular System Security forum. If possible, we want to keep the regular System Security forum filled with actual security problems,...
System Security
In need of a script...
I am looking for a script which can delete cookies, Windows + browser cache automatically on a regular (scheduled) basis. Can this be done through Windows itself or would i have to implement a custom script or something? I am looking to replace CCleaner and similar software package(s). Just now...
Performance & Maintenance
can't run script
Having a problem run this script at 1am /every:Friday c:\windows\shutdown.exe /l when I run it a black screen pop up and then disappears so I know the script is running but nothing is happen. I have ran it from the command line and it say access denial but I am in the local administrator...
Network & Sharing
What would be cool in windows (attn Admin)
You know, I think it would be cool if win did this: When uploading a file, there should be a search when trying to attach. Yes, no, maybe? PS. Admin, I was able to recover password. Thx
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd

All times are GMT -5. The time now is 22:31.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App