Navigate to a directory's only subdirectory (batch file)

If I use the "cd" command to navigate to a directory in my C: drive via a batch file, and in that directory there's only one subdirectory but I don't know its name, is there a way I can navigate
to that subdirectory? Is there some kind of environment variable I could use? Thanks in advance!

This works at a prompt:
for /f %i in ('dir /ad /b') do cd %i
If in a batch file it needs to be this:
for /f %%i in ('dir /ad /b') do cd %%i
¯\_(ツ)_/¯

Similar Messages

  • Cannot call 2 batch files .. executes only one batch and the program exists

    Hello,
    I am trying to call 2 batch files from the program . due to some reason only first batch file is called and second one is not called . any idea why it is happening.
    import java.util.Properties;
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.io.*;
    import java.io.File;
    import java.io.IOException;
    import java.io.InputStreamReader;
    public class MyBatchFiles {
          public static void main (String args[]) throws Exception {
        StringBuffer output  = new StringBuffer();
        StringBuffer error = new StringBuffer();
        try {
                   //call batch files
                   Process Process=Runtime.getRuntime().exec("cmd /c start F:\\batch1.bat"); // Batch File Path
                       Process.waitFor();
                      BufferedReader inputStreamReader  = new BufferedReader(new InputStreamReader(cubeBuildProcess.getInputStream()));
                   BufferedReader errStreamReader  = new BufferedReader(new InputStreamReader(cubeBuildProcess.getErrorStream()));
                   output = new StringBuffer();
                   error = new StringBuffer();
                   for(String ProcessLine;(ProcessLine=inputStreamReader.readLine())!=null;)
                             output.append(ProcessLine);
                   for(String ProcessLine;(ProcessLine=errStreamReader.readLine())!=null;)
                             error.append(ProcessLine);
                   System.out.println("transformer output = " + output);
                   System.out.println("transformer error = " + error);
                   if (error!=null){
                             //calling batch2
                             Process Process2=Runtime.getRuntime().exec("cmd /c start F:\\batch2.bat"); // Batch File Path
                             Process2.waitFor();
                             BufferedReader Process_inputStreamReader  = new BufferedReader(new InputStreamReader(Process2.getInputStream()));
                             BufferedReader Process_errStreamReader  = new BufferedReader(new InputStreamReader(Process2.getErrorStream()));
                             for(String ProcessLine1;(ProcessLine1=Process_inputStreamReader.readLine())!=null;)
                                       output.append(ProcessLine1);
                             for(String ProcessLine1;(ProcessLine1=Process_errStreamReader.readLine())!=null;)
                                       error.append(cubeCopyProcessLine);
           }catch(Exception e) {
                  e.printStackTrace();
    }Thanks
    Mike

    It's your if statement. Why do you think it could be happening?

  • Pass tablespace(s) as a parameter to RMAN using batch file (windows2000)

    I want to make a backup of one or more than one tablespaces.
    For Example:
    Backup tablespace USERS,TOOLS;
    Backup tablespace USERS;
    In this regards I am using windows batch file. Below you find the code of batch file which I am using to perform this operation (windows 2000)
    Batch file (c:\rman.cmd)
    set tbs1=%1
    set tbs2=,%2
    if exist tbs1 == goto usage
    if exist tbs2 == goto usage
    echo BACKUP tablespace %tbs1% %tbs2% ; > c:\temp\tbs.rman
    rman TARGET / @ c:\temp\tbs.rman
    Problem
    I run this batch file on command line .
    When I issue this command its ok and backed up both the tablespaces.
    Host @c:\rman.cmd USERS,TOOLS
    But when I want to backup only one tablespace and issue the command like that:
    Host @c:\rman.cmd USERS
    It gave the following error
    BACKUP tablespace users , ;
    Found comma after first tablespace.
    Point of focus
    How to get rid of the comma after first tablespace on run time, when I want to backup only one tablespace.
    BACKUP tablespace users , ;
    How to avoid that comma on run time when I only want to make a backup of single tablespace.
    Please check this matter it is only the batch file side problem.
    With Best Regards
    Fawad Ahmed

    I am not expert is DOS but I think you can fix this with
    a simple programming logic elements in the script.
    You have 2 cases:
    1 case ) When you have only one parameter
    2 case ) When you have more or equal than two parameters
    if exist tbs1 == goto mark1
    if exist tbs2 == goto mark2
    mark2:
    echo BACKUP tablespace %tbs1% %tbs2% ; > c:\temp\tbs.rman
    goto end
    mark1:
    echo BACKUP tablespace %tbs1% ; > c:\temp\tbs.rman
    goto end
    end:
    rman TARGET / @ c:\temp\tbs.rman
    This can be one the case for 1 or 2 parameters . If
    you think to pass more parameters you have to use
    another logic.
    I hope this can help you!
    Joel P�rez

  • Executing batch file as administrator changes working directory

    hey guys,
    I already posted this question on the msdn-forums and they sent me here. I hope, you can help me.
    My situation: I have a java program which I compile with exe4j. exe4j adds some nice features so I can install the program as a service with the command "myexe.exe /install"
    I put that command in a batch file (more user friendly).
    The problem: Only administrators can install services (in Win 7). But if I run the batch-file as administrator, the working directory changes to the system32-directory and I get an "command not found"-error.
    The question: How can I solve this? The only solution I know at the moment is setting a environment variable at installation time that points to the install-location. Is there another way?
    Thx for your help in advance

    With runas you in fact logon to another seesion. So cmd is started with his own starting directory (being where it is located, system32).
    I would recommend never to rely on the working dir for a batch file or script, but to always include the full path to the needed command/executables. If needed you can use environment variables to get the pathes of user-customised folders (for example the %usersprofile% variable).
    Using .lnk files (normal shortcuts) you can specify the working dir to start in if you would really need that functionality.
    MCSA/MCTS/MCP

  • Run_report_object in forms10g: Reports Server only accept batch jobs

    Hi all,
    We've migrated an old forms application to forms 10g R1. To run report objects from the form applications, I use the following code to run reports with a report server (10g):
    SET_REPORT_OBJECT_PROPERTY(l_rep_id,REPORT_FILENAME,'c:\path\to\report.rep'');
    SET_REPORT_OBJECT_PROPERTY(l_rep_id,REPORT_EXECUTION_MODE,BATCH);
    SET_REPORT_OBJECT_PROPERTY(l_rep_id,REPORT_COMM_MODE,ASYNCHRONOUS);
    SET_REPORT_OBJECT_PROPERTY(l_rep_id,REPORT_DESTYPE,CACHE);
    SET_REPORT_OBJECT_PROPERTY(l_rep_id,REPORT_DESFORMAT,'PDF');
    SET_REPORT_OBJECT_PROPERTY(l_rep_id,REPORT_SERVER,'repserver');
    l_rep_return := RUN_REPORT_OBJECT(l_rep_id, pl_id);
    The parameter pl_id is a pre-filled parameter list, and the parameter l_rep_id is the report_object, which was added to the reports-node in the fmb.
    By running this code, the reportserver successfully executes the report and via the report server queue I can open the created PDF file.
    But, as the report_comm_mode is set to ASYNCHRONOUS, the code doesn't wait until the reportserver has finished the execution of the report, so it's impossible to show the report by web.show_document. So I've set the report_comm_mode to SYNCHRONOUS:
    SET_REPORT_OBJECT_PROPERTY(l_rep_id,REPORT_FILENAME,'c:\path\to\report.rep'');
    SET_REPORT_OBJECT_PROPERTY(l_rep_id,REPORT_EXECUTION_MODE,BATCH);
    SET_REPORT_OBJECT_PROPERTY(l_rep_id,REPORT_COMM_MODE,SYNCHRONOUS);
    SET_REPORT_OBJECT_PROPERTY(l_rep_id,REPORT_DESTYPE,CACHE);
    SET_REPORT_OBJECT_PROPERTY(l_rep_id,REPORT_DESFORMAT,'PDF');
    SET_REPORT_OBJECT_PROPERTY(l_rep_id,REPORT_SERVER,'repserver');
    l_rep_return := RUN_REPORT_OBJECT(l_rep_id, pl_id);
    But when I executes this code, the execution of the report failes, and the following error code is shown in the report server queue:
    Terminated with error: REP-188: Reports Server only accept batch jobs
    But as you can see, the execution_mode is set to BATCH, so that is not the problem.
    Is there anyone who can help me to fix this problem?
    Regards,
    Jeroen

    I just sent you an e-mail, I hope it helps!

  • How to open a file in any directory not only in current  DIR

    hi
    i am new to java .
    i have written the code for opening a file and reading the opened file.
    i used filedialog to select a file for opening.
    problem is it is opening a file only in the cuurent working directory.
    i.e FileDialog.getFile() only returning the file name .what should i do to get the entire path of the file so that i can open a file any where in my System.

    plz give replies
    fileDialog.getDirectory() + fileDialog.getFile()

  • Custom batch rename files with Aperture 3 in the following format: IMG_0023.cr2 to Smith_YYMMDD_0023.cr2?  I cannot find a way to structure the date in Aperture as such, as well as extract only the camera file

    Please advise how to custom batch rename files with Aperture 3 in the following format: IMG_0023.cr2 to Smith_120816_0023.cr2?  I cannot find a way to structure the date in Aperture as such (YYMMDD), as well as extract only the camera file (0023, for example).  Adobe Bridge CS5 can do this, but NONE of the Adobe software is retina optimized, and is terrible to look at.

    In Aperture you are limited to renaming files by the entries in the File Naming preset window.
    At what point are you looking to rename, import or export? It might be possible to do what you are looking to do external to Aperture either via a script or other software.
    regards

  • When I use safari I keep getting a small coloured circular icon which in turn does not allow me to navigate at all.  the only way I can get rid of it is to shut down and reboot.  Can anyone help?

    When I use safari I keep getting a small coloured circular icon which in turn does not allow me to navigate at all.  the only way I can get rid of it is to shut down and reboot.  Can anyone help?

    Start here.

  • Polling a particular directory, retrieving only new files

    Hi,
    I have a requirement of polling a particular directory, and retrieving all new files posted. Say, i have a file called file1 in a particular directory, i keep polling the same directory every "n" minutes or even seconds, and will try to fetch file1 only when there is a semaphore file called file1.ready exists for file1.
    This is in Solaris.
    How can this be implemented?. Any help will be greatly appreciated.
    Thanks

    Take a look at java.io.File which represents an abstract path such as a directory or file. You'll probably be particularly interested in File.exists().

  • Polling a particular directory, retrieve only new file(s)?

    Hi,
    I have a requirement of polling a particular directory, and retrieving all new files posted. Say, i have a file called file1 in a particular directory, i keep polling the same directory every "n" minutes or even seconds, and will try to fetch file1 only when there is a semaphore file called file1.ready exists for file1.
    This is in Solaris.
    How can this be implemented?. Any help will be greatly appreciated.
    Thanks

    you can use the file modified dates to figure out whats new and whats old.
    May be you can compare them against the last time that you ran the process.

  • AFAB IM document type is defined only for batch input

    Hello Everybody,
    With the new version ECC6, I have this message error : "document type is defined only for batch input"  when I launch the monthly depreciation with AFAB transaction.
    Thanks a lot in advance for your help !
    Regards.

    Hi
    For this document type in OBA7, remove the check for 'batch input only'
    Thank You,

  • How to get folder(directory path only not file path) from local file system

    Hi Firends,
    How to get folder(directory path only not file path) from local file system , whenevr i will click on browse button.
    Please give reply for this one , if anybody knows.
    Thanks,
    Anderson.

    Hi Anderson,
    if you're using flash.filesystem.FileReference - then it is run in black box - except of filename, size and creation data (and few other properties available after some operation succeeded). This is part of security features in Flash runtime (described in header section):
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/FileReference .html
    This for example implies that user can download a content to local machine - but that content cannot be loaded back into Flash runtime. For this you would need either Air runtime flash.filesystem.File:
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.h tml
    (so you would created Air runtime based application: desktop or mobile but not web, even as standalone project) or you would need one of 3rd party tools that add file access/file information features to standard Flash runtime applications converted to standalone native applications.
    hth,
    kind regards,
    Peter

  • Setting jdk directory in batch file after installation

    Hello,
    Little problem : I need, under windows, to launch my application with a .bat cause i use the options -Xms and -Xmx of sun java compiler.
    So i need to get the jdk directory and put it in the batch file to be sure java.exe will be found.
    What could be a nice way to do this ? As nice, i mean i'd like the user don't edit the .bat to enter the path with keyboard.

    you could program a dialog, and create the .bat - file after testing, whether the selection (in a fileDialog, isDirectory (), check for starting that jvm) is valid.
    But this are two issues, independent from each other.
    You may call java -Xmx ... with or without leading path.

  • How to create a batch file to stop/start only essbase services 11.1.2.2

    Hi,
    I have a requirement to build a batch file to schedule stop or start essbase. This batch files should run daily once. Version 11.1.2.2.
    I have tried to prepare a batch file which is calling the default service restart batch StartEssbase.bat and stopEssbase.bat.
    Stop process is running fine. But, Start is not success. When I run StartEssbase.bat and stopEssbase.bat manually essbase is restarting successfully.
    I tried with the command like START ESSCMD.exe "Password" also. Still it is not working.
    Could any one please help with the batch scrpit how can I build to start or stop essbase.
    Thanks
    Srilatha Dasari

    Hi,
    You can use these...
    Start essbase-------------------------------
    REM ----------EssbaseAgent Start----------
    net start HyS9ESBAgent11.1.1_hypservice_1
    SET CHK46=%ERRORLEVEL%
    IF "%CHK46%" NEQ "0" (
         ECHO "ERROR IN STARTING THE ESSBASE SERVICE"
         EXIT /B 46
    ) ELSE (
         ECHO "STARTING ESSBASE SERVICE WAS SUCCESSFUL"
         EXIT /B 0
    PAUSE
    Stop essbase----------------------------------------
    REM ----------Stopping of ESSBASE Service----------
    SET ESB_BIN_DIR=E:\Hyperion\products\Essbase\EssbaseServer\bin
    SET SRCDIR=F:\Essbase\bin
    SET MSHSRC=%SRCDIR%\ShutdownServer.msh
    SET SERVERNAME=XXXXXXXX
    SET USERNAME=XXXXXX
    SET PASSWORD=XXXXX
    REM *****************CALLING ESSBASE ENVIRONMENT SCRIPT***********************
    CALL %ESB_BIN_DIR%\setEssbaseEnv.cmd
    CALL %ESB_BIN_DIR%\ESSMSH %MSHSRC% %USERNAME% %PASSWORD% %SERVERNAME%
    SET CHK10=%ERRORLEVEL%
    IF "%CHK10%" NEQ "0" (
         ECHO ------------------------------------------------------
         ECHO [%DATE% %TIME%] ERROR IN STOPPING THE ESSBASE SERVICE
         ECHO ------------------------------------------------------
         EXIT /B 10
    ) ELSE (
         ECHO ------------------------------------------------------
         ECHO [%DATE% %TIME%] STOPPING ESSBASE SERVICE WAS SUCCESSFUL
         ECHO ------------------------------------------------------
         EXIT /B 0
    The maxl is like
    login $1 $2 on $3;
    alter system shutdown;
    exit;
    Regards
    Snehasis

  • ESB Process reads a Batch file for a limited set of records only..?

    Dear All,
    I am having an ESB process that reads a Batch file (csv) that has around 10,000 Products information.
    I have another BPEL process that will create the Product in Oracle Apps through standard API (Main BPEL process that calls a child process for creating product).
    I am invoking the BPEL process from ESB, and that works fine.
    Now, the Issue is: I am able to create at a time around 10 Products (the main process calls the child process in a loop.). The main process instance is not getting created but the child process instance is getting created for a set of records, afterwards the child process instances get stops creating. The main process instance could not be found in the console. Not getting why the process is not getting visible as well it is not completing the process.
    What could be the problem for this... Am I need to change any environment configurations...?
    Please update...
    Many Thanks in advance...

    Does this apply to you?
    https://social.technet.microsoft.com/Forums/en-US/9ccd8e50-b0af-4f58-9787-6435834e4c52/dfsr-not-working-on-new-windows-2008r2-server
    Thanks for the link, but no - not the same scenario although the error is the same.   The RGs I'm working with are all in sync and communication is working, it's just getting the backlog reported correctly.
    To reiterate, I can paste two versions of the exact command into the DOS window buffer; one copied from OneNote and one copied from my batch file.  Executing the one from OneNote succeeds and reports the RG in sync and the one copied from the batch
    file fails.
    I can repeat the results by up arrow once to the command pasted into the buffer from the batch file and see it fail.  Then up arrow twice to retrieve the command pasted from OneNote into the buffer and it will report correctly (illustrated in the grahic).
    Let me add that the command in the batch file was originally copied from OneNote and pasted in to the batch file; as if going into the batch file somehow corrupts it.
    - a -

Maybe you are looking for