Showing posts with label Folder. Show all posts
Showing posts with label Folder. Show all posts

March 14, 2022

Change default directory of Windows command prompt and Windows PowerShell

 Hi all,

Today I will explain the steps to change the default directory for Windows command prompt and Windows PowerShell.

The default directory for both the command prompt and PowerShell is the "system32" folder of the OS installed directory (By default: "C:\windows\system32").

Day in - Day out, we will open the terminals (command prompt / PowerShell) and navigate the source directory. It sometimes irritates and wastes lots of time.

I have come across this situation and want to avoid re-entry the change directory command.

Environment,

I use the command prompt and PowerShell, which are pinned to the taskbar of Windows.


Change default directory of Windows Command Prompt

  1. Right-click on the taskbar pinned Command Prompt icon
  2. Right-click on the "Command Prompt" menu
  3. Select the "Properties" item
  4. Under the "Shortcut" tab, you will find the "Start in:" label
  5. In the respective text box, enter the path you want to navigate by default.
  6. For example, "C:\Projects".

Change default directory of Windows PowerShell

  1. Open the PowerShell with administrator privileges
  2. Create a profile by using the following steps
    1. New-item -type file -force $Profile
  3. This will create a file "Microsoft.PowerShell_profile.ps1" in the current user documents PowerShell folder.
    1. Syntax
        • C:\Users\<UserName>\Documents\WindowsPowerShell
      1. Example
          • C:\Users\PSR\Documents\WindowsPowerShell
      2. Edit file
          • notepad.exe $Profile
        1. Change the default directory
          1. Syntax
              • Set-Location <Directory Path>
            1. Example
                • Set-Location C:\Projects
                  • Clear-Host # To clear the PowerShell screen
              1. Save and close the file
              2. In the PowerShell window, enter the following command to change the profile
                  • . $Profile
                1. It immediately changes from the current directory to the updated default directory.
                2. Close the PowerShell and try to open the PowerShell again to see the change in the directory.
                Hope the above information is helpful to you reduce the change directories in day-to-day life.

                Send me your valuable feedback to psrdotcom@gmail.com.

                March 06, 2020

                View docker image file content with folder structure

                Hi folks,

                I have come across a scenario where I need to see the image contents.

                Yes, I want to view the image content with hierarchy.

                Then I found this dive, which has done it beautifully.

                Install on Ubuntu PC


                1. # wget https://github.com/wagoodman/dive/releases/download/v0.9.2/dive_0.9.2_linux_amd64.deb
                2. # sudo apt install ./dive_0.9.2_linux_amd64.deb

                Usage


                • Get the docker images list
                  • # docker image list
                • Choose the image which you want to explore by copying the "Repository" name
                • Run the command
                  • # dive
                • It takes some time to analyse and display the image contents in hierarchical manner.
                • Of the left side, it will have the image layers
                • Select the appropriate image layer with up/down arrow keys
                • By pressing the "Tab" you will be able to switch to right side view where your files are available
                • Use space to expand/collapse the folder
                • Dive will display each folder size
                • See the sample docker image contents with dive below




                • To quit/exit from the dive, use Ctrl+C


                Hope this is helpful

                Please send your feedback and comments to psrdotcom@gmail.com

                March 03, 2020

                Run local file server with NPM http-server

                Hi folks,

                Today i'll explian the process of making your folder as a standalone file server.

                Objective

                Make my folder contents browse over http

                Procedure


                • Install Node
                • Install http-server module in node globally
                  • npm install -g http-server
                • Open terminal/command-prompt
                • Navigate to your folder
                • Run the following command to start the server
                  • http-server .
                • or simply run
                  • hs .
                • Run from anywhere with full path of the folder
                  • hs C:\FileFolder
                • Starting up http-server, serving .
                • Available on:
                  • http://10.10.6.2:8080
                  • http://127.0.0.1:8080
                  • http://youripaddress:8080
                • Hit CTRL-C to stop the server
                • You should be able to browse your file folder contents with any of the above URLs
                Hope you are able to access your file contents over the browser

                Tip: Using this approach, you can share your content over intranet/internet with full control over data as read only.

                After stopped the server, access to the folder is stopped.

                Please send your comments and feedback to psrdotcom@gmail.com

                May 30, 2017

                Compress folders/files and create .tar.gz (Tar archive with GunZip Compression) and .zip (ZIP compression) file in Java

                Hi friends,

                Today I will explain how easily we can compress files and folders in java.

                I have used a third part library which so simple to use.

                Download the .jar from the following URL
                https://rauschig.org/jarchivelib/download.html

                Now, create a java class and create .tar.gz and .zip files.

                Sample source code

                package gunziptest;

                import java.io.File;
                import java.io.IOException;
                import java.util.logging.Level;
                import java.util.logging.Logger;
                import org.rauschig.jarchivelib.ArchiveFormat;
                import org.rauschig.jarchivelib.Archiver;
                import org.rauschig.jarchivelib.ArchiverFactory;
                import org.rauschig.jarchivelib.CompressionType;

                /**
                 *
                 * @author psrdotcom
                 */
                public class GunZipTest {

                    /**
                     * @param args the command line arguments
                     */
                    public static void main(String[] args) {
                        // Archive file name
                        String archiveName = "archive";
                        // test is destination folder
                        File destination = new File("test");
                        // source folder has files and sub-folders
                        File archive = null;
                        
                        // zip compression
                        Archiver archiver = ArchiverFactory.createArchiver(ArchiveFormat.ZIP);
                        try {
                            archive = archiver.create(archiveName, destination, source);
                            if(archive != null && archive.isFile()) {
                                System.out.println("gunziptest.GunZipTest.main()" + "zip file created");
                            }
                        } catch (IOException ex) {
                            Logger.getLogger(GunZipTest.class.getName()).log(Level.SEVERE, null, ex);
                        }

                        // tar.gz compression
                        archiver = ArchiverFactory.createArchiver(ArchiveFormat.TAR, CompressionType.GZIP);
                        try {
                            archive = archiver.create(archiveName, destination, source);
                            if(archive != null && archive.isFile()) {
                                System.out.println("gunziptest.GunZipTest.main()" + "zip file created");
                            }
                        } catch (IOException ex) {
                            Logger.getLogger(GunZipTest.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    }
                }

                Hope, you will find this useful.

                Please send your review and feedback to psrdotcom@gmail.com

                January 20, 2017

                Change EOL (End Of Line) Character from Windows to Unix/Linux for all the files in current working directory

                Hi all,

                For a single file, you can do the change of EOL using notepad++.
                Reference: http://psrdotcom.blogspot.in/2017/01/change-eol-end-of-line-character-from.html

                But it would be difficult, if you want to do for multiple files in one go.

                I have found a solution to update EOL for all files in the current directory.

                Pre-requisite

                Make sure that, working directory contains only the files which you want to change EOL.

                Note: If not, copy the files to a new directory and change the EOL for all the files in that directory.

                Procedure

                1. Download dos2unix utility from sourceforge https://sourceforge.net/projects/dos2unix/
                2. Extract the zip file
                3. Tip: Make sure that the extracted path doesn't contain spaces.
                4. Keep the bin directory available in your PATH environment variables
                5. Download the customized batch file from GIST https://gist.github.com/psrdotcom/d73ff9590c3010253b5b2a886704b26b
                6. Extract if needed, and place the "dos2unixfolder.bat" in the same directory where the "dos2unix" is placed.
                7. Tip: If you place the batch file in the same folder of dos2unix.exe. You no need to add again the patch of batch file in environment PATH.
                8. Navigate to your folder, where you want all the files EOL to be changed
                9. Press "Right Click on Mouse" in empty area
                10. Select "Open Command Prompt Here"
                11. Type the batch file name "dos2unixfolder.bat"
                12. You will able to see the conversion process
                13. Once the conversion is completed, you can check the EOL coversion in notepad++.
                14. If you need to help in checking, refer to http://psrdotcom.blogspot.in/2017/01/change-eol-end-of-line-character-from.html


                Please send your comments and feedback to psrdotcom@gmail.com

                Change EOL (End Of Line) Character from Windows to Unix/Linux using Notepad++

                Hi all,

                Today I will explain about updating/converting EOL for a single file from windows format to unix/linux format.

                1. In Windows, the EOL (End-Of-Line) character is \r\n (CR LF) (Carriage Return, Line Feed)
                2. In Unix/Linux, the EOL character is \n (LF) (Line Feed)

                Check for EOL

                If you open the file in notepad++, you will be able to see the EOL character by following below steps:


                • Type the content and hit enter button on keyboard
                • Choose menu "View -> Show Symbol"
                • Check the "Show End of Line" option

                • Now, you will be able to view "CR LF" special symbols in you file at every line end as show below

                Update EOL

                To convert the EOL from Windows (CR LF) to Unix (LF), do the following

                • Click on "Edit" menu
                • Choose "EOL Conversion"
                • Select "Unix(LF)"

                • Now, you can check the update EOL character in your file. Example conversion show below

                This type of conversion useful, when you are updating file in windows and using the same file in U/Linux environment.

                Batch File Update

                For all files in one folder, you can follow my blog.
                Reference: http://psrdotcom.blogspot.in/2017/01/change-eol-end-of-line-character-from_20.html

                Send your comments and feedback to psrdotcom@gmail.com

                January 03, 2016

                Nexus 7 Files accessing (storage drive) issue fix after upgrading to Marshmallow

                Hi friends,

                Today when I connected my Nexus 7 tab, I was unable to see the drive and folder structure. But in the file explorer it is able to detect the Nexus 7 by showing the icon. When you double click to view the files, there is nothing.
                1. After googling, the following solutions worked for me.
                2. Go to device management
                3. Right click Android ADB Interface and do uninstall
                4. After uninstalling the drivers, change the USB type in Nexus to PTP and immediately change to MTP
                5. Unplug and plug the Nexus to your PC
                6. Now the system will re-install the driver
                Hope, this post will be useful when OS upgraded and unable to access file system of device

                Android 6.0.1 Upgrade fix

                After installing the driver, device might be recognized but we need to change the "Use USB for options" from any one of the following options

                Notification Panel

                1. Select the "USB for file transfer - Touch for more options"
                2. You will be prompted to choose any one of the following
                  • Charging
                  • File transfers
                  • Photo transfers
                  • MIDI
                3. Select File transfers to see the "Internal Storage"

                Developer Options

                1. Go to "Settings->Developer Options"
                2. Go to "Select USB Configuration" setting
                3. Choose "MTP (Media Transfer Protocol)" for transferring the files
                Now you should be able to see the file storage in explorer

                Please send your feedback and comments to psrdotcom@gmail.com

                November 27, 2015

                Creating Symbolic Link (Symlink) in Windows 7

                Hi friends,

                In Linux, it is easy to create symbolic link (symlink) with "ln" command.
                But what about in windows?

                I found one GUI and command for creating the symbolic links in windows.

                Pre-requisites

                1. Visual Studio 2005 redistributable
                2. Link Shell Extension
                3. Download the above executables from here based on OS and system architecture
                4. For Windows 7 64-bit, I have downloaded the following highlighted in black box

                Procedure

                • Install the Visual Studio 2005 redistributable
                • Install Link Shell Extension
                • You should be able to see an option in context menu
                • Select the file/folder
                • Right click and select the option "Pick Link Source"

                • Now, the file is been picked
                • Navigate to go the destination folder where you want to create the symbolic link
                • Right click on the empty space of the folder
                • Select Drop As and select "Hardlink or Symbolic Link" based on your requirement


                • You should be able to see the file type as .symlink


                References

                http://www.howtogeek.com/howto/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux/

                Please send your feedback and comments to psrdotcom@gmail.com

                January 19, 2015

                Windows: Copy all file names in a folder

                Hi friends,

                I’ve got a requirement like, I want to copy all the file names from a folder in Windows.

                After searching from Google, I’ve got one of the quick solution which is being described below

                Procedure:

                Navigate to the folder where you want to copy all the file name in “Windows Explorer”

                Select all the files (Key Board (KB) Shortcut: Ctrl + a)

                Press and hold the “Shift” key on your keyboard

                Right click your mouse by pointing to any one of the selected file

                From the context menu, select the option “Copy as path”

                Now, open “Notepad”

                Paste the content (KB Shortcut: Ctrl + v)

                Now, you will be able to see all the file name with full path

                You can remove the folder path, if you don’t want the full path

                Enjoy guys Smile

                Send your comments and feedback to psrdotcom@gmail.com

                Blogger Labels: Windows,Copy,folder,requirement,Google,solution,Procedure,Navigate,Explorer,Select,Board,Shortcut,Ctrl,Shift,From,context,menu,option,path,Notepad,Paste,Enjoy,Send,feedback

                June 18, 2013

                Unable to Share folders in Ubuntu problem got resolved (Samba)

                Hi friends,

                I was not able to share my folders within network sometime back.

                After searching and modifying configuration file my problem got resolved.

                Problem: 

                Unable to share Ubuntu folders

                Message:  

                net usershare' returned error 255: net usershare add: cannot share path /opt/foldingathome as we are restricted to only sharing directories we own.
                Ask the administrator to add the line "usershare owner only = False"
                to the [global] section of the smb.conf to allow this.

                Resolution:

                1. Type the following in console
                  • $ sudo vi /etc/samba/smb.conf
                2. Go to [global] section
                3. Add the following line
                  • usershare owner only = False
                4. Save and exit from vi
                5. Restart Samba service
                  • sudo service samba restart
                Now, you can happily share your folders over network

                Please send your feedback and comments to psrdotcom@gmail.com
                 

                Featured Post

                Java Introdcution

                Please send your review and feedback to psrdotcom@gmail.com