w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Getting just the current directory without the full path in python
Like this: os.path.split(os.getcwd())[1] Although os.path.split returns a tuple, you don't need to unpack it. You can simply select the item that you need and ignore the one that you don't need.

Categories : Python

Xtend how to get full path of current working directory
Yes, Java has a File class. You can create one by calling this constructor which takes a String. Then you can call getAbsolutePath() on it. You can call it like this: package com.sandbox; import java.io.File; public class Sandbox { public static void main(String[] args) { File file = new File("relative path"); String absolutePathString = file.getAbsolutePath(); } }

Categories : Java

Python joining current directory and parent directory with os.path.join
You can use normpath, realpath or abspath: import os goal_dir = os.path.join(os.getcwd(), "../../my_dir") print goal_dir # prints C:/here/I/am/../../my_dir print os.path.normpath(goal_dir) # prints C:/here/my_dir print os.path.realpath(goal_dir) # prints C:/here/my_dir print os.path.abspath(goal_dir) # prints C:/here/my_dir

Categories : Python

get filenames from a directory without full path
Use Path.GetFileName which returns file name and extension from full path var files = Directory.GetFiles(directory).Select(f => Path.GetFileName(f)); Or even var files = Directory.GetFiles(directory).Select(Path.GetFileName);

Categories : C#

Directory.GetFiles() returns full path
You can use Path.GetFileName: string[] ImageNames = Directory.GetFiles(path) .Select(p => Path.GetFileName(p)).ToArray(); This will produce a list with only the names of the files.

Categories : C#

Find the root directory without full path in C#
If the subfolder is under the same root as you application you can use Directory.GetDirectoryRoot See: http://msdn.microsoft.com/en-us/library/system.io.directory.getdirectoryroot.aspx

Categories : C#

How do I update a link with a full directory path with jQuery URI?
OK, I figured this out with a whole bunch more googling. The function that works for what I needed is: var handler = function (data, href, target) { // Insert data into div $( '#' + target ).html(data); console.log("href = ", href); // Convert relative URLs in #right to include directory var base_path = URI(href).directory(); //var base_path = uri.directory() + '/'; console.log(base_path); $('#right a:uri(is: relative)').each(function() { var cur_href = $(this).attr("href"); $(this).attr("href", base_path+"/"+cur_href); }); }; The change is to use .each to allow an anonymous function to do the work on each relative link.

Categories : Javascript

How to get full directory path of the file on browse in Firefox and IE using javascript?
You do not need full file path from the client browser since it will have nothing to do with the uploaded destination on the server. Many browsers restrict full local path availability due to security concerns. IE will show full path if you add site to "Trusted Sites", but again there is no need for that.

Categories : Javascript

how to get the full path of sdcard directory in android phonegap with javascript?
Please try this code.. There is window.appRootDir.fullPath through you get full path but before that you must use dirReady(); <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title> Insert title here </title> <script type="text/javascript" src="lib/android/cordova-1.7.0.js"> </script> <script type="text/javascript"> window.appRootDirName = "download_test"; document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { console.log("device is ready");

Categories : Javascript

How to show buffers without full path?
You can't change the format of :ls. It shows paths relative to your current working directory (:pwd). You can change the current working directory either via :cd or :lcd. Also you might find the option :help 'autochdir' interesting, too. EDIT: I should clarify on relative here: Files within the current working directory are shown relative and files outside of it are shown absolute. Absolute paths can be shortened, e.g. by using ~ instead of /home/user on Unix systems.

Categories : Vim

How to get current working directory path of a Qt application?
your application cannot know where the project is, because this is a qt-creator option. if you want to run your binary in the project path you have to setup your working directory inside qt-creator to the right path. then the QDir::currentPath() will return the path you want to have. goto: projects->[environment]->run-> working directory

Categories : C++

How to find a file path in current java directory
Try: String path = System.getProperty("user.dir"); path = path.replaceAll("\","/") + "/etc/xsd/template.xsd" Source: String.replaceAll with Backslashes error

Categories : Misc

SVN: checkout from multiple URLs to the current working directory under same path?
You can get needed result, while and if COMMON and HOST files are stored in the same repository You use SVN 1.6 or later (I'll recommend to start using 1.8) Solution is file-based externals: re-read carefully "Externals Definitions" in SVN-Book, starting from words Subversion 1.6 also introduced support for external definitions for files. File externals are configured just like externals for directories and appear as a versioned file in the working copy. I.e you files in common/nagios/etc + common/nagios/objects will be maintained files, files inside HOST-tree - externals to files in COMMON (if all files have unique names). Checkouted HOST-tree will have all files in Working Copy (if externals wasn't disabled on checkout)

Categories : Svn

python unipath: path to current file directory (ancestor) outputs nothing
Use os.path.abspath(__file__) instead of __file__. This is because __file__ contains a relative path in your case. __file__ can contain a relative path or an absolute one in different situations: So, if you aren't inside the part of sys.path that contains the module, you'll get an absolute path. If you are inside the part of sys.path that contains the module, you'll get a relative path. If you load a module in the current directory, and the current directory isn't in sys.path, you'll get an absolute path. If you load a module in the current directory, and the current directory is in sys.path, you'll get a relative path. (quote from Python __file__ attribute absolute or relative?)

Categories : Python

Batch File: Error in relative path , one level up from the current directory
Your attempt to use %~1 to go up one level in the directory structure is inventive and totally invalid syntax. The proper syntax is just as simple - use ... A leading is not required because %~dp0 ends with a . %windir%Microsoft.NETFrameworkv4.0.30319InstallUtil.exe %~dp0..inERecruitGenerateReportsWindowsService.exe

Categories : Windows

File path completion relative to the current file directory
Filename-completion is always done from the working directory. If you always want to do things relative to the current file, you can add set autochdir to your ~/.vimrc. You can change the working directory for the current window with :lcd %:p:h See :help 'autochdir', :help :lcd and :help filename-modifiers.

Categories : Node Js

How to show online offline status on Unix via putty
You can use netstat to see if some port (used by the service) is open or not. ubuntu@ip:~/$ netstat -na --inet | grep LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN ubuntu@ip:~/$ Or for FTP: netstat -na --inet | grep 21 I'm not sure what exactly does this command "svcs -a" (I did not use Solaris). But perhaps this command could help service --status-all Works on RedHat-like systems (SystemV init style). It shows all services' current status [root@dgdevlin bin]# service --status-all acpid (pid 3409) is running... adlagent (pid 3738) is running... anacron is stopped atd (pid 3657) is running... Also, if your linux is Ubuntu(-based) you can use this command initctl list It shows a list of services. For each service it shows configured

Categories : Unix

getting the full filenames from all top directory files in a specific directory and suppressing the occuring error
Did I understand correctly that you only need the File-names with directory-names. This code works for me, no elevations needed. private void button1_Click(object sender, EventArgs e) { string folder = @"C:windowsprefetch"; string filemask = @"*.pf"; string[] filelist = Directory.GetFiles(folder, (filemask)); //now use filelist[i] for any operations. }

Categories : C#

PHP: fopen path for `include`d script using Apache Document Root when full path is specified?
If the Path starts with / It will point to the root Filesystem which is fine with CLI but CGI would understand it this way: /home/jweinberger/com.example/logs/script1.log//home/jweinberger/logs/script1.log You should use the index 'DOCUMENT_ROOT' from the $_SERVER array. fopen($_SERVER['DOCUMENT_ROOT'].'/home/jweinberger/logs/script1.log')

Categories : PHP

Replace part of a path which has multiple occurrences into full path name by a string
1st solution: change batch code and call file #: @echo off &setlocal enabledelayedexpansion set mypath="D:android-sdkandroid-sdk-windows#workspace" SET "mypath=!mypath:%~1=*!" echo %mypath% "D:android-sdkandroid-sdk-windows*workspace" 2nd solution: use sed @echo off &setlocal set "mypath=D:android-sdkandroid-sdk-windowsKworkspace" for /f %%i in ('echo(%mypath%^|sed s/%~1/*/') do set "mypath=%%i" echo %mypath% "D:android-sdkandroid-sdk-windows*workspace"

Categories : Batch File

404 redirect works but changes rewritten URL path in browser to full URL path
You need to add conditions before each of your rewrites to ensure you're not blindly rewriting into a file that doesn't exist. Mainly, the 4 rules at the end need to have some conditions: RewriteCond %{REQUEST_URI} ^/([A-Za-z0-9_-]+)/?$ RewriteCond %{DOCUMENT_ROOT}/pages/%1/%1.php -f RewriteRule ^ pages/%1/%1.php [NC,L] The first condition creates a grouping which is backreferenced using %1. The second condition creates a path that you are trying to rewrite to and checks if that file exists using -f. Same thing for the others: RewriteCond %{REQUEST_URI} ^/([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)/?$ RewriteCond %{DOCUMENT_ROOT}/pages/%1/%2/%2.php -f RewriteRule ^ pages/%1/%2/%2.php [NC,L] RewriteCond %{REQUEST_URI} ^/([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)/?$ RewriteCond %{DOCUMENT

Categories : Htaccess

asp.net MVC saving relative path in database as not the full path
If your question is "How to save as full path", please try this string path = Path.Combine(Server.MapPath("~/Content/img/Company/LogoFiles"), filename); If your question is "How to save as relative path", please try this [HttpPost] public ActionResult Save(HttpPostedFileBase myFile) { string filename = myFile.FileName; string relativeFileName = "~/Content/Uploads/" + filename;// relative path return View(); }

Categories : Sql Server

How to change the current working directory to a specific directory and execute a program under the specific directory?
One of your principal problems is that you don't capture the return value (output) of the command in backticks. You are merely throwing away the output you want. Do something like: my $output = `perl ./script.pl` system("perl ./script.pl")

Categories : Perl

Use absolute full path to the img instead of the local path
Try: my_path = "/images/myimage.jpg"; See Why would a developer place a forward slash at the start of each relative path? to understand the function of the forward slash in this context.

Categories : Javascript

After I deleted a directory, it always prompts "shell-init error retrieving current directory getcwd solve" when log on bash
When opening a new shell or xterm, it's started in the working directory of the process that started it. If you e.g. cd /proc && xterm, the new terminal will place you in /proc. Whatever's starting your terminal had positioned itself in /home/desktop/zeno, and now all the terminals are trying to start there. If you make that process change directory (by rebooting, for example), the terminals will start in a directory that exists and you will no longer get this error.

Categories : Linux

Django under IIS (with HeliconZoo) in virtual directory - urls resolver works with path without directory name
Finally, I've found what's wrong with it. Appeared that the reason for described behavior is a setting provided with default web.config file: <add name="django.root" value="%APPL_VIRTUAL_PATH%" /> After I removed it everything started working fine. Here is some info related to django.root variable applied to Apache.

Categories : Django

Directory.Delete(path, true) throws IOException "The directory is not empty"
It appears that info.EnumerateFiles was the issue. I got that idea from this answer. I switched that to info.GetFiles and I was then able to delete the directory after.

Categories : C#

How to resolve a relative directory path to canonical path in MATLAB/Octave
The simplest way I know to convert a path to its canonical form is using cd command: oPath = cd(cd(iPath)); Note that this would fail if the path does not exist on your file system.

Categories : Matlab

How to make $_SERVER['DOCUMENT_ROOT'] reference to alias directory path and NOT wamp default path?
I think you would be better creating a Virtual host for each of your projects. HowTo setup Virtual Hosts

Categories : Apache

Get path two directories above the path to current class file
If you create a File from the URL you can call getParentFile() on it: URL fileUrl = Test.class.getProtectionDomain().getCodeSource().getLocation(); File file = new File(fileUrl.toURI); String grandParent = file.getParentFile().getParent(); This should also work: String grandParent = Test.class.getResource("../../").toString();

Categories : Java

PHP: Does file_exists($path) check sub directory of $path ? how computationally intensive it is?
I'm not sure if you mean does file_exists($path) check subdirectories of path or if it checks subdirectories of the current working directory for path. In either case the answer is no. $path is taken simply as a path and the method confirms whether or not that file/directory exists.

Categories : PHP

How to print the name of my current directory's parent directory
You can use ${PWD%/*}: $ echo $PWD /home/me/test/t $ echo ${PWD%/*} /home/me/test As the expression ${string%substring} Strips shortest match of $substring from back of $string (reference).

Categories : Shell

Get the current directory name via php script in another directory
I am not 100% sure of your questions, but it sounds like you are looking for the URL/Directory of the page you are currently on, not the directory of the header? What about: $_SERVER['PHP_SELF']; $_SERVER['REQUEST_URI']; $_SERVER['SCRIPT_NAME']; $_SERVER['SCRIPT_FILENAME']; $_SERVER['DOCUMENT_ROOT']; Those all give info about the current file open by the server based on the HTTP request it received.

Categories : PHP

Using the FileWriter with a full path
Make sure you add trailing backslashes to the path parameter so the path is recognized as a directory. The example provide is for a Windows OS which uses backslashes that are escaped. For a more robust method use the file.separator property for the system. Works writeToFile("D:\Documents and Settings\me\Desktop\Development\", "this is a test"); Doesn't Work writeToFile("D:\Documents and Settings\me\Desktop\Development", "this is a test"); File Separator Example String fs = System.getProperty("file.separator"); String path = fs + "Documents and Settings" + fs + "me" + fs + "Desktop" + fs + "Development" + fs; writeToFile(path, "this is a test");

Categories : Java

Creating a full directory tree at once
Change shebang to #!/bin/bash to run the script with bash as it supports brace expansion. The problem is that you are using shell that does not support it. Your /bin/sh does not point to /bin/bash but to something like /bin/dash. https://wiki.ubuntu.com/DashAsBinSh#A.7B

Categories : Linux

Function for getting full directory structure
You don't have to check. os.walk always returns a tuple in a form: (current_directory, directory_list, files_list) So you always know that the second element of the tuple is a list of directories found in the current_directory, and that the third element is a list of files found in the current_directory. You should use os.walk in that manner: for current, directories, files in os.walk(path): # do your stuff...

Categories : Python

Show every file in a directory, but don't show files that are currently being copied
There's no "current files being copied" list stored anywhere in Windows/.NET/whatever. Probably the most you could do is attempt to open each file for append and see if you get an exception. Depending on the size and location of your directory, and on the security setup, that may not be an option.

Categories : C#

Get application full path in Node.js
There's probably a better solution, BUT this should work: var path = require('path'); // find the first module to be loaded var topModule = module; while(topModule.parent) topModule = topModule.parent; var appDir = path.dirname(topModule.filename); console.log(appDir); EDIT: Andreas proposed a better solution in the comments: path.dirname(require.main.filename) EDIT: another solution by Nam Nguyen path.dirname(process.mainModule.filename)

Categories : Node Js

In Bootstrap FileStyle how do I use the full path?
I see that the Bootstrap FileStyle plugin start from a standard input file element. So you can get its value by: $("input[type=file]").val(); Demo code: $(document).ready(function () { $(":file").filestyle({ classButton: "btn btn-primary" }); $("#getFileName").click(function () { alert($("input[type=file]").val()); }); }); Demo: http://jsfiddle.net/IrvinDominin/8CpnH/ EDIT If you want to get the full path name you'll face a "problem" not related to the plugin, but to browser security reasons. You can check some related and deep questions on SO like How to get full path of selected file on change of <input type=‘file’> using javascript, jquery-ajax?

Categories : Javascript

How a get full path of hidden files?
You can use: for /f "delims=" %%p in ('dir /B /S /A *.ext') do echo %%p A option /A includes a hidden files.

Categories : Batch File



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.