- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Microsoft
- >
- Re: how to write a batch file in windows??
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-24-2006 05:01 AM
тАО08-24-2006 05:01 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-24-2006 06:18 AM
тАО08-24-2006 06:18 AM
SolutionBatch file is nothing but a way of executing combination of commands.
For instance a delete command like what you want....
say you want to delete all files in a particular folder(abc)
so open notepad --- type---del c:\abc\*.*
Save this file as del.bat with file type as all files.
Similarly you can use other command along with it in the same batch file ---compressing command and ftp commands...
Regards,
V
(Points appreciated :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-24-2006 07:12 AM
тАО08-24-2006 07:12 AM
Re: how to write a batch file in windows??
--------------------------------
@echo off
rem .:-------------------------------------
rem .: Delete all files within a folder
rem .:-------------------------------------
set /P my_folder="Please enter folder to delete files within: "
if exist %my_folder% goto do_dfile
goto error
:do_dfile
cd %my_folder%
del /F *.*
del /F /AH *.*
goto done
:error
echo Folder was not found.
:done
rem .:-------------------------------------
rem .: End of delete script
rem .:-------------------------------------
==============================================================
@echo off
rem .:-------------------------------------
rem .: Compress (Zip?) then FTP files
rem .:-------------------------------------
set /P my_folder="Please enter folder to zip and FTP: "
if exist %my_folder% goto do_zfile
goto error
:do_zfile
cd %my_folder%
rem .: if your date has '/' in the date, they need to be stripped out.
for /f "delims='/'" %%i in ('%date%') do
set my_date=%%i-%%j-%%k
zip_program /switches *.* %my_date%.zip
set /P my_loc="Please enter FTP site: "
set /P my_id="Please enter your ID: "
set /P my_pass="Please enter your Password: "
echo open %my_loc% > ftp_conn.txt
echo user %my_id% %my_pass%>> ftp_conn.txt
echo binary >> ftp_conn.txt
echo hash >> ftp_conn.txt
echo put %my_date%.zip >> ftp_conn.txt
echo close >> ftp_conn.txt
echo quit >> ftp_conn.txt
ftp -s:ftp_conn.txt
del ftp_conn.txt
del %my_date%.zip
goto done
:error
echo Folder was not found.
:done
rem .:-------------------------------------
rem .: End of zip/ftp script
rem .:-------------------------------------
Jon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-24-2006 07:30 AM
тАО08-24-2006 07:30 AM
Re: how to write a batch file in windows??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-24-2006 06:04 PM
тАО08-24-2006 06:04 PM
Re: how to write a batch file in windows??
Tyep
del /s *.*
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2006 04:03 AM
тАО08-25-2006 04:03 AM
Re: how to write a batch file in windows??
rmdir my_folder or
rmdir /s my_folder
This will also remove the specified folder, so if you are in the folder, you need to go up a level ../ prior to issuing the command.
Jon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2006 04:11 AM
тАО08-25-2006 04:11 AM
Re: how to write a batch file in windows??
del *.* /s or del /s *.* isn't working
it's deleting only files not subfolders. why?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2006 04:18 AM
тАО08-25-2006 04:18 AM
Re: how to write a batch file in windows??
after that command i have message ...(somenamefiles)\*.*
what if i want to delete files in current directory and all subfolder within.
del *.* /s or del /s *.* isn't working
it's deleting only files not subfolders. why? i don't want to delete directory that i'm in.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2006 06:32 AM
тАО08-25-2006 06:32 AM
Re: how to write a batch file in windows??
I have made some changes to the original commands which Jon had given( which I hope Jon does not mind-Jon pls don't sue me for copyright infringement). Now what this does is since u want to delete the sub directories and files the only way to do that is to delete the directory itself. Now your problem was that you want to delete the original folder contents but leave the folder alone but that's not possible with the command RD or RMDIR so what had to be done is delete the folder and create another folder under the same directory with the same name. And so that's what this does --> deletes folder and all subfolders and then creates a folder with the same name
@echo off
rem .:-------------------------------------
rem .: Delete all files within a folder
rem .:-------------------------------------
set /P my_folder="Please enter folder to delete files within: "
if exist %my_folder% goto do_dfile
goto error
:do_dfile
rd /s %my_folder%
md %my_folder%
goto done
:error
echo Folder was not found.
:done
rem .:-------------------------------------
rem .: End of delete script
rem .:-------------------------------------
Simple ain't it, now on a very personal note i would like to say that u r asking these questions to your peers so please add a couple of pleases and thank yous in your posts. we ain't your slaves just your ordinary technogeeks(of which i do not consider myself worthy to be part of).
Regards,
Shijo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2006 07:49 AM
тАО08-25-2006 07:49 AM
Re: how to write a batch file in windows??
cd %my_folder%
del /F *.*
del /F /AH *.*
for /f %%i in ('dir /b /ad') do
rmdir %my_folder%\%%i
goto done
Jon