How to open folder ?!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • viktorijakup
    New Member
    • Sep 2008
    • 10

    How to open folder ?!

    Hi !!!

    This script must open folder, and I must view empty opened folder...!!!
    I work in "Far manager".

    Now this script only create folder...

    Code:
    @rem = '--*-Perl-*--
    @echo off
    if "%OS%" == "Windows_NT" goto WinNT
    perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
    goto endofperl
    :WinNT
    perl -x -S %0 %*
    if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
    if %errorlevel% == 9009 echo You do not have Perl in your PATH.
    if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
    goto endofperl
    @rem ';
    #!/usr/bin/perl
    use warnings;
    use strict;
    use File::Path;
    use Cwd;
    use File::Copy;
    use File::Spec::Functions;
    #hardcoded 
    my $FP = 'Y:\graphics_qc';
    my $TP = 'Y:\plot_db';
    my ($from_file, $to_file) = ($ARGV[0], $ARGV[0]);
    my $cwd = `cd`;
    chomp $cwd;
    my ($from_dir, $to_dir) = ($cwd, $cwd);
    #rename dir part
    $to_dir =~ s/^\Q$FP\E/$TP/;
    mkpath($to_dir);
    chdir $to_file;
    exit 0;
    
    __END__
    :endofperl
    Regards !!!

    Viki
  • nithinpes
    Recognized Expert Contributor
    • Dec 2007
    • 410

    #2
    If you want to physically open the folder (get the view of folder contents), use:
    Code:
    system("start $to_dir");  # this will open folder in win explorer
    Else, if you want to open the folder to read its contents(files) inside Perl script, use opendir() command.
    Code:
    opendir(DIR,"$to_dir") or die "failed to open:$!";
    while(<DIR>) { # read through contents of folder

    Comment

    • viktorijakup
      New Member
      • Sep 2008
      • 10

      #3
      Hi !!!

      Thank you for answer !!!

      Code:
           1. system("start $to_dir"); # this will open folder in win explorer
      I need the same opening folder in "Far manager".

      :)


      Regards !!!

      Viki






      Originally posted by nithinpes
      If you want to physically open the folder (get the view of folder contents), use:
      Code:
      system("start $to_dir");  # this will open folder in win explorer
      Else, if you want to open the folder to read its contents(files) inside Perl script, use opendir() command.
      Code:
      opendir(DIR,"$to_dir") or die "failed to open:$!";
      while(<DIR>) { # read through contents of folder

      Comment

      • numberwhun
        Recognized Expert Moderator Specialist
        • May 2007
        • 3467

        #4
        I don't know about anyone else, but I have no idea what "Far Manager" is and have never heard of it. If it is an external program, then that is up to you to figure out. Otherwise, please explain what your needs are a little clearer.

        Regards,

        Jeff

        Comment

        • nithinpes
          Recognized Expert Contributor
          • Dec 2007
          • 410

          #5
          I do not know about "Far Manager" either. However, if you know of a method to open a file/folder in Far manager through command prompt, then you should be able to do it using the same command inside system() in your script.

          Comment

          • KevinADC
            Recognized Expert Specialist
            • Jan 2007
            • 4092

            #6
            I have a funny feeling he means File Manager.....

            Comment

            • Icecrack
              Recognized Expert New Member
              • Sep 2008
              • 174

              #7
              hey guys,

              http://www.farmanager. com/

              if its in the default then its should be

              Code:
              system(`c:\program files\far\far.exe`);

              Comment

              • KevinADC
                Recognized Expert Specialist
                • Jan 2007
                • 4092

                #8
                looks like the old DOS interface I used to work with more than 15 years ago.

                Comment

                • Icecrack
                  Recognized Expert New Member
                  • Sep 2008
                  • 174

                  #9
                  just to help this fella out i thought ill put in some command line argv


                  Code:
                   /?   This help.
                   /a   Disable display of characters with codes 0 - 31 and 255.
                   /ag  Disable display of pseudographics characters.
                   /8   Forces FAR to work in ANSI (non-Unicode) console.
                   /e[<line>[:<pos>]] <filename>
                        Edit the specified file.
                   /i   Set small (16x16) icon for FAR console window.
                   /p[<path>]
                        Search for "common" plugins in the directory, specified by <path>.
                   /co  Forces FAR to load plugins from the cache only.
                   /rc  Restore console windows settings upon exiting FAR.
                   /u <username>
                        Allows to have separate settings for different users.
                   /v <filename>
                        View the specified file. If <filename> is -, data is read from the stdin.
                   /x   Disable exception handling.

                  Comment

                  Working...