Or place the text in a file called file.txt and use this:
Code: Select all
@echo off
for /f "delims=" %%a in (file.txt) do echo(%%a
pause
Moderator: DosItHelp
Code: Select all
@echo off
for /f "delims=" %%a in (file.txt) do echo(%%a
pause
Code: Select all
@if (@CodeSection == @Batch) @then
@echo off
setlocal
rem Place your original Batch code here
rem Activate the pop-up GUI and get the folder
for /F "delims=" %%a in ('CScript //nologo //E:JScript "%~F0"') do (
set selectedFolder=%%a
)
rem Process the selected folder in any way you wish
echo Selected folder: "%selectedFolder%"
goto :EOF
End of Batch section
@end
// JScript section
// Creates a dialog box that enables the user to select a folder and display it.
var title = "Select a folder", rootFolder = 5;
var shl = new ActiveXObject("Shell.Application");
var folder = shl.BrowseForFolder(0, title, 0, rootFolder);
WScript.Stdout.WriteLine(folder ? folder.self.path : "");
Code: Select all
@echo off
setlocal EnableDelayedExpansion
set i=0
for %%a in (" ______ __ __ ________ ______ ______ __ __ ________ "
" / \ / | _ / |/ | / \ / \ / \ / |/ |"
"/$$$$$$ |$$ | / \ $$ |$$$$$$$$/ /$$$$$$ |/$$$$$$ |$$ \ /$$ |$$$$$$$$/ "
"$$ |__$$ |$$ |/$ \$$ |$$ |__ $$ \__$$/ $$ | $$ |$$$ \ /$$$ |$$ |__ "
"$$ $$ |$$ /$$$ $$ |$$ | $$ \ $$ | $$ |$$$$ /$$$$ |$$ | "
"$$$$$$$$ |$$ $$/$$ $$ |$$$$$/ $$$$$$ |$$ | $$ |$$ $$ $$/$$ |$$$$$/ "
"$$ | $$ |$$$$/ $$$$ |$$ |_____ / \__$$ |$$ \__$$ |$$ |$$$/ $$ |$$ |_____ "
"$$ | $$ |$$$/ $$$ |$$ |$$ $$/ $$ $$/ $$ | $/ $$ |$$ |"
"$$/ $$/ $$/ $$/ $$$$$$$$/ $$$$$$/ $$$$$$/ $$/ $$/ $$$$$$$$/"
) do (
set /A i+=1
set "line[!i!]=%%~a"
)
for /L %%i in (1,1,%i%) do echo !line[%%i]!
Aacini wrote:Ops! Why he did changed the topic at the middle of it! (bad idea )
Ok, new answer to new topic!Code: Select all
@echo off
setlocal EnableDelayedExpansion
set i=0
for %%a in (" ______ __ __ ________ ______ ______ __ __ ________ "
" / \ / | _ / |/ | / \ / \ / \ / |/ |"
"/$$$$$$ |$$ | / \ $$ |$$$$$$$$/ /$$$$$$ |/$$$$$$ |$$ \ /$$ |$$$$$$$$/ "
"$$ |__$$ |$$ |/$ \$$ |$$ |__ $$ \__$$/ $$ | $$ |$$$ \ /$$$ |$$ |__ "
"$$ $$ |$$ /$$$ $$ |$$ | $$ \ $$ | $$ |$$$$ /$$$$ |$$ | "
"$$$$$$$$ |$$ $$/$$ $$ |$$$$$/ $$$$$$ |$$ | $$ |$$ $$ $$/$$ |$$$$$/ "
"$$ | $$ |$$$$/ $$$$ |$$ |_____ / \__$$ |$$ \__$$ |$$ |$$$/ $$ |$$ |_____ "
"$$ | $$ |$$$/ $$$ |$$ |$$ $$/ $$ $$/ $$ | $/ $$ |$$ |"
"$$/ $$/ $$/ $$/ $$$$$$$$/ $$$$$$/ $$$$$$/ $$/ $$/ $$$$$$$$/"
) do (
set /A i+=1
set "line[!i!]=%%~a"
)
for /L %%i in (1,1,%i%) do echo !line[%%i]!
Antonio
MeSH wrote:about your post above this.. sorry but i gave up on that i don't get it i think i need to dig more for gaining knowledge...
Code: Select all
@if (@CodeSection == @Batch) @then
@echo off
title TEST
:MAIN
echo Testing files (Y/N)
set "cho="
set /p "cho=>"
if /i %cho%==Y goto INSTALL1
if /i %cho%==N goto EXIT
echo Invalid choice
goto MAIN
:INSTALL1
mkdir UserBackup
for /F "delims=" %%a in ('CScript //nologo //E:JScript "%~F0"') do (
set Destination_Folder=%%a
)
XCopy "NewFolder\NewFolder_2\*.*" "%Destination_Folder%\*.*" /c /s /r /d /y /i > "UserBackup\Logfile_NewFolder_2.log"
pause>nul
:EXIT
exit
@end
// Creates a dialog box that enables the user to select a folder and display it.
var title = "Select a folder", rootFolder = 0;
var shl = new ActiveXObject("Shell.Application");
var folder = shl.BrowseForFolder(0, title, 0, rootFolder);
WScript.Stdout.WriteLine(folder ? folder.self.path : "");
Aacini wrote:MeSH wrote:about your post above this.. sorry but i gave up on that i don't get it i think i need to dig more for gaining knowledge...
My code is a substitute of abc0502's one. I taken the program you posted under "is this correct sir?" comment and replaced the :VBS: code by my own. Here it is:Code: Select all
@if (@CodeSection == @Batch) @then
@echo off
title TEST
:MAIN
echo Testing files (Y/N)
set "cho="
set /p "cho=>"
if /i %cho%==Y goto INSTALL1
if /i %cho%==N goto EXIT
echo Invalid choice
goto MAIN
:INSTALL1
mkdir UserBackup
for /F "delims=" %%a in ('CScript //nologo //E:JScript "%~F0"') do (
set Destination_Folder=%%a
)
XCopy "NewFolder\NewFolder_2\*.*" "%Destination_Folder%\*.*" /c /s /r /d /y /i > "UserBackup\Logfile_NewFolder_2.log"
pause>nul
:EXIT
exit
@end
// Creates a dialog box that enables the user to select a folder and display it.
var title = "Select a folder", rootFolder = 0;
var shl = new ActiveXObject("Shell.Application");
var folder = shl.BrowseForFolder(0, title, 0, rootFolder);
WScript.Stdout.WriteLine(folder ? folder.self.path : "");
Antonio
Code: Select all
@echo off
setlocal EnableDelayedExpansion
set i=0
for %%a in (" ______ __ __ ________ ______ ______ __ __ ________ "
" / \ / | _ / |/ | / \ / \ / \ / |/ |"
"/$$$$$$ |$$ | / \ $$ |$$$$$$$$/ /$$$$$$ |/$$$$$$ |$$ \ /$$ |$$$$$$$$/ "
"$$ |__$$ |$$ |/$ \$$ |$$ |__ $$ \__$$/ $$ | $$ |$$$ \ /$$$ |$$ |__ "
"$$ $$ |$$ /$$$ $$ |$$ | $$ \ $$ | $$ |$$$$ /$$$$ |$$ | "
"$$$$$$$$ |$$ $$/$$ $$ |$$$$$/ $$$$$$ |$$ | $$ |$$ $$ $$/$$ |$$$$$/ "
"$$ | $$ |$$$$/ $$$$ |$$ |_____ / \__$$ |$$ \__$$ |$$ |$$$/ $$ |$$ |_____ "
"$$ | $$ |$$$/ $$$ |$$ |$$ $$/ $$ $$/ $$ | $/ $$ |$$ |"
"$$/ $$/ $$/ $$/ $$$$$$$$/ $$$$$$/ $$$$$$/ $$/ $$/ $$$$$$$$/"
) do (
set /A i+=1
set "line[!i!]=%%~a"
)
for /L %%i in (1,1,%i%) do echo !line[%%i]!
MeSH wrote:is there a possible way to align to center?
Code: Select all
C:\Documents and Settings\Antonio\My Documents\ASMB\Batch File Programming\tests
>type test.bat
@echo off
setlocal EnableDelayedExpansion
set i=0
for %%a in (" _____ _ _ _ _____ _____ _____ _____ _____ "
"| _ | | | | __| __| | | __|"
"| | | | | __|__ | | | | | | __|"
"|__|__|_____|_____|_____|_____|_|_|_|_____|"
) do (
set /A i+=1
set "line[!i!]=%%~a"
)
set "leftMargin= "
for /L %%i in (1,1,%i%) do echo %leftMargin%!line[%%i]!
C:\Documents and Settings\Antonio\My Documents\ASMB\Batch File Programming\tests
>test
_____ _ _ _ _____ _____ _____ _____ _____
| _ | | | | __| __| | | __|
| | | | | __|__ | | | | | | __|
|__|__|_____|_____|_____|_____|_|_|_|_____|
Code: Select all
C:\Documents and Settings\Antonio\My Documents\ASMB\Batch File Programming\tests
>type Center.bat
@echo off
rem Show a file centered in the command-window
rem Load file lines into an array
set i=0
for /F "usebackq delims=" %%a in (%1) do (
set /A i+=1
set "line[!i!]=%%a"
)
rem Get the left margin (first line define the wide)
for /L %%a in (1,1,80) do if "!line[1]:~%%a,1!" neq "" set linesWide=%%a
for /F "tokens=1,2" %%a in ('mode con') do if "%%a" equ "Columns:" set columns=%%b
set /A leftCols=(columns-linesWide)/2
set leftMargin=
for /L %%a in (1,1,%leftCols%) do set "leftMargin=!leftMargin! "
rem Show the file centered
for /L %%i in (1,1,%i%) do echo %leftMargin%!line[%%i]!
C:\Documents and Settings\Antonio\My Documents\ASMB\Batch File Programming\tests
>type awesome.txt
_____ _ _ _ _____ _____ _____ _____ _____
| _ | | | | __| __| | | __|
| | | | | __|__ | | | | | | __|
|__|__|_____|_____|_____|_____|_|_|_|_____|
C:\Documents and Settings\Antonio\My Documents\ASMB\Batch File Programming\tests
>Center.bat awesome.txt
_____ _ _ _ _____ _____ _____ _____ _____
| _ | | | | __| __| | | __|
| | | | | __|__ | | | | | | __|
|__|__|_____|_____|_____|_____|_|_|_|_____|
MeSH wrote:thank you Antonio! I used the no. 1 the no. 2 example is confusing me :facepalm
I'm using now and it's really great! my script has designs now
NEW QUESTION
how to delete a single word or number in a directory name?
like this one
in the "New Folder" directory there are 3 sub-folder
Folder_Set_1
Folder_Set_2
Folder_Set_3
I want is to delete the "_" so that this will be the result:
FolderSet1
FolderSet2
FolderSet3
how can I make that on batch script? please help me sir... I can't find in the internet the command for that (or the right word for that)
Code: Select all
echo off
set "folder=Folder_Set_1"
set "var=%folder:_=%"
ren "%folder%" "%var%"
foxidrive wrote:Here's one technique:Code: Select all
echo off
set "folder=Folder_Set_1"
set "var=%folder:_=%"
ren "%folder%" "%var%"
Code: Select all
@echo off
for /f "delims=" %%a in (' dir /ad /b ') do (
set "folder=%%a"
setlocal enabledelayedexpansion
set "folder=!folder:_=!"
ren "%%a" "!folder!"
endlocal
)
pause
foxidrive wrote:Code: Select all
echo off
for /f "delims=" %%a in (' dir /ad /b ')
set "folder=%%a"
setlocal enabledelayedexpansion
set "folder=!folder:_=!"
ren "%%a" "!folder!"
endlocal
)
pause