HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Microsoft
- >
- Re: batch file for finding full path of a file
Operating System - Microsoft
        1839901
        Members
    
    
        3254
        Online
    
    
        110156
        Solutions
    
Forums
        Categories
Company
Local Language
                
                  
                  back
                
        
                
        
                
        
                
        
        
        
                
        
                
        
        
        
                
        
              
              Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
                
                  
                  back
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
            
                
            
                
            
                
            
                
            
            
                
            
                
            
            
                
            
                
              
            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
Blogs
        Information
        Community
Resources
Community Language
        Language
        Forums
Blogs
Topic Options
			
				
					
	
			
		
	- 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
05-29-2007 06:11 PM
05-29-2007 06:11 PM
			
				
					
						
							batch file for finding full path of a file
						
					
					
				
			
		
	
			
	
	
	
	
	
			
				
					
					
						Hi experts,
I am new to batch file scripting.can any body help me to create a batch file which accepts a file name from the user.this file name has to be searched in the computer and the full path should be returned.if the file doesnt exist it should display an error.
awaiting your reply
thanx in advance
					
				
			
			
				
			
			
				
			
			
			
			
			
			
		
		
		
	
	
	
I am new to batch file scripting.can any body help me to create a batch file which accepts a file name from the user.this file name has to be searched in the computer and the full path should be returned.if the file doesnt exist it should display an error.
awaiting your reply
thanx in advance
		3 REPLIES 3
	
	            
            
		
		
			
            
                - Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2007 10:54 PM
05-29-2007 10:54 PM
			
				
					
						
							Re: batch file for finding full path of a file
						
					
					
				
			
		
	
			
	
	
	
	
	
			
				
					
					
						I don't know how to convert this into a batch file but this is how it's done from the Command Prompt:
CD\
DIR /s
Make a great day!
Roger 
					
				
			
			
				
		
		
	
	
	
CD\
DIR
Make a great day!
Roger
	Make a great day!
Roger
			
			
				
			
			
			
			
			
			
		Roger
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2007 09:28 PM
05-30-2007 09:28 PM
			
				
					
						
							Re: batch file for finding full path of a file
						
					
					
				
			
		
	
			
	
	
	
	
	
			
				
					
					
						Hi Prajith,
@echo off
cd \
set /p fileName="Insert file name to be searched.: "
title searching file
echo.
dir %filename% /s
pause
Note: if the file has blanks between words, users must use ""
Example:
Insert file name: "NCRM TaskForce Minutes 2006_11_15.doc"
hope that will do.
Tnks.
		
		
	
	
	
@echo off
cd \
set /p fileName="Insert file name to be searched.: "
title searching file
echo.
dir %filename% /s
pause
Note: if the file has blanks between words, users must use ""
Example:
Insert file name: "NCRM TaskForce Minutes 2006_11_15.doc"
hope that will do.
Tnks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2007 10:15 PM
05-30-2007 10:15 PM
			
				
					
						
							Re: batch file for finding full path of a file
						
					
					
				
			
		
	
			
	
	
	
	
	
			
				
					
					
						hi prajith,
You can run this bath like this example:
FilePath.bat filename
If the file file as spaces between you have to use "" like for example:
FilePath.bat "file name.txt"
Note: All files found will be outputted in the end, and the last or only file found will be saved in the variable %filepath" so you can used it latter or even used it on another script.
***copy the following code to a text file, and change the extension to .bat or .cmd.***
::----------------------------------------
@echo off
set filename=%1
set filenamePath="%userprofile%\desktop\filenamePath.txt"
c:
cd\
dir %filename% /s/b | findstr %filename% > %filenamePath%
for /f "usebackq tokens=1 delims=" %%i in (%filenamePath%) do (
set filePath=%%i
)
type %filenamepath%
del %filenamePath%
::------------------------------------------
I don't really know why you need this, since a "dir /s/a filename" will find the file you need, but here it is anyway.
Hope this helps,
best regards,
Hugo Tigre
		
		
	
	
	
You can run this bath like this example:
FilePath.bat filename
If the file file as spaces between you have to use "" like for example:
FilePath.bat "file name.txt"
Note: All files found will be outputted in the end, and the last or only file found will be saved in the variable %filepath" so you can used it latter or even used it on another script.
***copy the following code to a text file, and change the extension to .bat or .cmd.***
::----------------------------------------
@echo off
set filename=%1
set filenamePath="%userprofile%\desktop\filenamePath.txt"
c:
cd\
dir %filename% /s/b | findstr %filename% > %filenamePath%
for /f "usebackq tokens=1 delims=" %%i in (%filenamePath%) do (
set filePath=%%i
)
type %filenamepath%
del %filenamePath%
::------------------------------------------
I don't really know why you need this, since a "dir /s/a filename" will find the file you need, but here it is anyway.
Hope this helps,
best regards,
Hugo Tigre
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
		
	
	
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP
