how can i find a file and edit it in notepad

January 2, 2011 at 05:04:35
Specs: Windows 7
i want to make a bat file that can search for a file then opens that file in notepad
my version of this program is not completed yet but this is what i want :
{NOTE}


dir /b /s FILE.ini
{after the file is found "FILE.ini" i want to put this file with its location "c:\somewhere\FILE.ini" to be assigned as a variable "AAA"}
{like set AAA = "the location of the file after the search is done" }
{so the variable AAA should have this value after the command is done "c:\somewhere\FILE.ini"}
start notepad.exe !AAA!

______________________________
any ideas will be appreciated , thnx a lot in advance ....


See More: how can i find a file and edit it in notepad

Report •


#1
January 2, 2011 at 10:38:20
FOR /f "tokens=*" %%a IN ('DIR /b /s "myfile"') DO SET AAA=%%a
START notepad.exe "%AAA%"

Can I put a question here?


Report •

#2
January 2, 2011 at 11:35:09
nice answer but it didn't work
i need to find a specific file e.g(FILE.txt)
and then i need to edit it in notepad .now when i run my program
this is what it gives me:

C:\user\>dir /b /s FILE.txt
C:\user\somewhere\FILE.txt
C:\user\>

now i want the next command to take "C:\user\somewhere\FILE.txt"
and assign it to variable AAA

how to do it??

____________________________________
very thankful about your answer and if u can explain your command it would be very helpful & thanks Again for you response .......



Report •

#3
January 2, 2011 at 11:56:54
Actually it does work. You asked for a batch file, but what you are showing in reply #2 is the command prompt.

Run it in a batch file as I posted before, or remove one of the % from both of the variables (%%a) and run it from the prompt.

----

FOR /f "tokens=*" %a IN ('DIR /b /s "myfile"') DO SET AAA=%a
START notepad.exe "%AAA%"

Can I put a question here?


Report •

Related Solutions

#4
January 2, 2011 at 13:37:25
L O V E u Very Much

excellent commands , if u want to check my little program down here. Just copy past

:: Finally THX 2 Matt123 & SAFWAN
:: coCreated BY SAFWAN
@echo off
setlocal enableextensions enabledelayedexpansion
Title File Editor
echo . . . .
echo . .
echo ةححححححححححححححححححححححححححححححححححححححححححححححححححححححححححححححححححححح»
echo ؛ Programed by SAFWAN and Matt123 ؛
echo جححححححححححححححححححححححححححححححححححححححححححححححححححححححححححححححححححححح¹
echo ؛ these types are supported (*.txt;*.ini;*.inf;*.bat;*.css;*.vbs) ؛
echo ؛ and all kinds of editable files in NOTEPAD.exe ؛
echo بححححححححححححححححححححححححححححححححححححححححححححححححححححححححححححححححححححح¼
echo . .
echo . . . .
echo - just write down the name of the file :
set /p FILEnAME=
FOR /f "tokens=*" %%a IN ('DIR /b /s "!FILEnAME!"') DO SET AAA=%%a
echo .
echo .
echo %AAA%
START notepad.exe "%AAA%"
echo .
echo .
pause

thanx a lot


Report •

#5
January 2, 2011 at 13:50:40
"these types are supported (*.txt;*.ini;*.inf;*.bat;*.css;*.vbs)"

...

And if I input "blabla35435v" your script wont work.

@echo off
:MAIN
cls
echo.
set /p INPUT= Enter a valid extension (TXT, INI, INF, BAT, CSS, VBS) :
echo.
if %INPUT%==TXT goto LAB_TXT
if %INPUT%==INI goto LAB_INI
if %INPUT%==INF goto LAB_INF
if %INPUT%==BAT goto LAB_BAT
if %INPUT%==CSS goto LAB_CSS
if %INPUT%==VBS goto LAB_VBS
if not "%INPUT%" equ " a" goto WRONG

:WRONG
echo Wrong input extension..please enter a valid extension.
pause>nul
goto MAIN

...

Regards,

Happy is ONE who says I am an OttoMAN.


Report •

#6
January 2, 2011 at 13:53:42
if not "%INPUT%" equ " a" goto WRONG
Enter a valid extension (TXT, INI, INF, BAT, CSS, VBS) : a
Now what?

How To Ask Questions The Smart Way


Report •

#7
January 2, 2011 at 13:55:23
http://pastebin.com/ search for "bYYY_Safwan_13526"

Report •

#8
January 2, 2011 at 13:59:00
That's my debugging .. thing lol.

if someone's input is something else then the "if %input%==.." it does go to the label WRONG.

And label WRONG contains, echo, etc.

Happy is ONE who says I am an OttoMAN.


Report •

#9
January 2, 2011 at 15:37:58
Why not just use:

...
GOTO wrong
...
?

Can I put a question here?


Report •

#10
January 2, 2011 at 16:02:00
Ugh, your right :c

Thanks!

Happy is ONE who says I am an OttoMAN.


Report •

#11
January 2, 2011 at 16:09:29
Haha, just trying to help MUs. ;)

Can I put a question here?


Report •

#12
April 22, 2011 at 13:19:46
cls
@ECHO OFF
title Folder Locker
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Locker goto MDLOCKER
:CONFIRM
echo Are you ariewayq(Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM
:LOCK
ren Locker "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto End
:UNLOCK
echo Enter my name to Unlock folder
set/p "pass=>"
if NOT %pass%==type your password here goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Locker
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDLOCKER
md Locker
echo Locker created successfully
goto End
:End

save this file. click 2times
good luck

http://terryraban.blogspot.com/


Report •


Ask Question