elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recopilación Tutoriales y Manuales Hacking, Seguridad, Privacidad, Hardware, etc


  Mostrar Mensajes
Páginas: 1 ... 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 [887] 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 ... 1236
8861  Programación / .NET (C#, VB.NET, ASP) / Re: Visual basic studio (WTF?) fallo del ide en: 12 Junio 2013, 14:42 pm
Te propongo una posible solución alternativa:

Paso 1:
Usar la aplicación "Uninstall Tool" para desinstalar todo rastro posible de tu instalación de VS (elige la opción de forzar borrado en el setup.exe del VS2012 para desinstalar todos los paquetes adicionales también). "http://www.crystalidea.com/uninstall-tool"
(No me sirve que uses CCleaner ni que lo desinstales manuálmente desde el instalador)

Paso 2:
Volver a instalar VS:
-> By Elektor H@cker: MEGA-PACK para iniciarse en .NET (VS2012 + Recursos + Tools)

Saludos
8862  Programación / Scripting / Re: Ayuda Script batch/powershell en: 12 Junio 2013, 13:24 pm
Es muy sencillo:

Código
  1. @Echo OFF
  2. Setlocal enabledelayedexpansion
  3.  
  4. Set "File=kk.txt"
  5. Set /A "Cut=14" & REM Las lineas que queremos conservar, desde abajo.
  6.  
  7. FOR /F %%@ IN ('Type "%File%" ^| Find /v /c ""') DO (Set /A "Length=%%@-%Cut%")
  8.  
  9. for /f "tokens=1* delims=]" %%A in ('Type "%File%" ^| Find /n /v ""') do (
  10. Set /A "Line+=1"
  11. If !Line! GTR %length% (Echo %%B)
  12. )
  13.  
  14. Pause&Exit

PD1: ten en cuenta que ninguna línea empiece con el caracter: "]"

PD2: Para una mayor eficacia primero deberías hacerle un "reverse" el archivo de texto (darle la vuelta para que las lineas de abajo queden arriba del todo, y así se procesan primero) y usar el primer script en lugar de este último.

Hay muchas aplicaciones commandline para manejar archivos de texto y efectuar todo tipo de acciones... una de ellas es Tail:

Código
  1. Tail.exe --lines=14 "kk.txt"
(Con eso consigues hacer lo mismo que hace mi último script)

Saludos
8863  Programación / Scripting / Re: Ayuda Script batch/powershell en: 12 Junio 2013, 12:56 pm
Entonces usa esto:

Código
  1. @Echo OFF
  2. Setlocal enabledelayedexpansion
  3.  
  4. FOR /F "Usebackq Tokens=*" %%@ IN ("1.txt") DO (
  5. Set /A "Line+=1"
  6. If not !Line! GTR 14 (Echo %%@)
  7. )
  8.  
  9. Pause&Exit

Saludos
8864  Programación / Scripting / Re: Ayuda Script batch/powershell en: 12 Junio 2013, 11:48 am
Hola,

Antes de nada, haz el favor de leer mi firma.

Y prueba a usar el siguiente script, de esta manera:
Código
  1. TextMan.bat SR 1 14 "kk.txt"    

Saludos!





TextMan.bat:
Código
  1. @Echo OFF
  2.  
  3.  
  4. :: TEXT MANIPULATOR ROUTINE v0.5
  5. :: by Elektro H@cker
  6.  
  7.  
  8. REM SYNTAX:
  9. ::
  10. :: TEXTMAN [ACTION] [LINE(S)] [FILE] [TEXT]
  11. ::
  12. :: * [LINE(S)] parameter is Optional for some actions
  13. :: * [TEXT] parameter is Optional for some actions
  14.  
  15.  
  16. REM ACTIONS:
  17. ::
  18. ::  AB  = ADD_BEGINNING      * Add text to the beginning of a line.
  19. ::  AE  = ADD_ENDING         * Add text to the end of a line.
  20. ::  E   = ERASE              * Delete a line.
  21. ::  I   = INSERT             * Add a empty line (Or a line with text).
  22. ::  RL  = REPLACE_LINE       * Replace a entire line.
  23. ::  RS  = REPLACE_STRING     * Replace word from line.
  24. ::  RSA = REPLACE_STRING_ALL * Replace word from all lines.
  25. ::  C+  = CHARACTER_PLUS     * Delete the first "X" characters from all lines.
  26. ::  C-  = CHARACTER_LESS     * Delete the last  "X" characters from all lines.
  27. ::  L+  = LINE_PLUS          * Cut the first "X" amount of lines.
  28. ::  L-  = LINE_LESS          * Cut the last  "X" amount of lines.
  29. ::  GL  = GET_LINE           * Delete all except "X" line.
  30. ::  GR  = GET_RANGE          * Delete all except "X" range of lines.
  31.  
  32.  
  33. REM EXAMPLES:
  34. ::
  35. :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: ::
  36. ::                                                                         ::
  37. :: Delete the line 3                                                       ::
  38. :: Call :TEXTMAN E 3 "Test.txt"                                            ::
  39. ::                                                                         ::                                                                        
  40. :: Add a string to the beginning of line 3                                 ::
  41. :: Call :TEXTMAN AL 3 "Test.txt" "Elektro H@cker"                          ::
  42. ::                                                                         ::                                                                      
  43. :: Add a string to the end of line 3.                                      ::
  44. :: Call :TEXTMAN AR 3 "Test.txt" "Elektro H@cker"                          ::
  45. ::                                                                         ::                                                                      
  46. :: Add a empty line at line 3.                                             ::
  47. :: Call :TEXTMAN I 3 "Test.txt"                                            ::
  48. ::                                                                         ::                                                                      
  49. :: Add a line with a word at line 3.                                       ::
  50. :: Call :TEXTMAN I 3 "Test.txt" "Elektro H@cker"                           ::
  51. ::                                                                         ::    
  52. :: Replace the line 3 with "Elektro H@cker".                               ::
  53. :: Call :TEXTMAN RL 3 "Test.txt" "Elektro H@cker"                          ::
  54. ::                                                                         ::
  55. :: Replace the words "Elektro" to "H@cker" in line 3.                      ::
  56. :: Call :TEXTMAN RS 3 "Test.txt" "Elektro" "H@cker"                        ::
  57. ::                                                                         ::
  58. :: Replace the words "Elektro" to "H@cker" in all lines.                   ::
  59. :: Call :TEXTMAN RSA "Test.txt" "Elektro" "H@cker"                         ::
  60. ::                                                                         ::
  61. :: Delete the first 3 characters in all lines.                             ::
  62. :: Call :TEXTMAN C+ 3 "Test.txt"                                           ::
  63. ::                                                                         ::
  64. :: Delete the last 3 characters in all lines.                              ::
  65. :: Call :TEXTMAN C- 3 "Test.txt"                                           ::
  66. ::                                                                         ::
  67. :: Delete the first 3 lines.                                               ::
  68. :: Call :TEXTMAN L+ 3 "Test.txt"                                           ::
  69. ::                                                                         ::
  70. :: Delete the last 3 lines.                                                ::
  71. :: Call :TEXTMAN L- 3 "Test.txt"                                           ::
  72. ::                                                                         ::
  73. :: Delete all except the line number 3.                                    ::
  74. :: Call :TEXTMAN SL 3 "Test.txt"                                           ::
  75. ::                                                                         ::
  76. :: Delete all except the 3 to 9 range of lines.                            ::
  77. :: Call :TEXTMAN SR 3 9 "Test.txt"                                         ::
  78. ::                                                                         ::
  79. :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: ::
  80.  
  81.  
  82. :TEXTMAN
  83. (SET /A "A=0", "LINE=0", "TOTAL_LINES=0")  &  (CALL :%~1 %* || (ECHO Invalid parameter & Exit /B 1)) & (GOTO:EOF)
  84. :AB
  85. (For /F "tokens=1* delims=]" %%A in ('type "%~3" ^| find /n /v ""') DO (Call Set /A "LINE+=1" && (CMD /C "IF NOT "%%LINE%%" EQU "%~2" (if "%%B" EQU "" (Echo+>> "%~3.NEW") ELSE ((Echo %%B)>> "%~3.NEW")) ELSE (if "%%B" EQU "" ((Echo %~4)>> "%~3.NEW") ELSE ((Echo %~4%%B)>> "%~3.NEW"))"))) && (CALL :RENAMER "%~3") & (GOTO:EOF)
  86. :AE
  87. (For /F "tokens=1* delims=]" %%A in ('type "%~3" ^| find /n /v ""') DO (Call Set /A "LINE+=1" && (CMD /C "IF NOT "%%LINE%%" EQU "%~2" (if "%%B" EQU "" (Echo+>> "%~3.NEW") ELSE ((Echo %%B)>> "%~3.NEW")) ELSE ((Echo %%B%~4)>> "%~3.NEW")"))) && (CALL :RENAMER "%~3") & (GOTO:EOF)
  88. :E
  89. (For /F "tokens=1* delims=]" %%A in ('type "%~3" ^| find /n /v ""') DO (Call Set /A "LINE+=1" && (CMD /C "IF NOT "%%LINE%%" EQU "%~2" (if "%%B" EQU "" (Echo+>> "%~3.NEW") ELSE ((Echo %%B) >> "%~3.NEW"))"))) && (CALL :RENAMER "%~3") & (GOTO:EOF)
  90. :I
  91. (For /F "tokens=1* delims=]" %%A in ('type "%~3" ^| find /n /v ""') DO (Call Set /A "LINE+=1" && (CMD /C "IF     "%%LINE%%" EQU "%~2" (IF NOT "%~4" EQU "" ((Echo %~4) >> "%~3.NEW") ELSE (Echo+>> "%~3.NEW"))" & (if "%%B" EQU "" (Echo+>> "%~3.NEW") ELSE ((Echo %%B)>> "%~3.NEW"))))) && (CALL :RENAMER "%~3") & (GOTO:EOF)
  92. :RL
  93. (For /F "tokens=1* delims=]" %%A in ('type "%~3" ^| find /n /v ""') DO (Call Set /A "LINE+=1" && (CMD /C "IF NOT "%%LINE%%" EQU "%~2" (if "%%B" EQU "" (Echo+>> "%~3.NEW") ELSE ((Echo %%B)>> "%~3.NEW")) ELSE ((Echo %~4)>> "%~3.NEW")"))) && (CALL :RENAMER "%~3") & (GOTO:EOF)
  94. :RS
  95. (For /F "tokens=1* delims=]" %%A in ('type "%~3" ^| find /n /v ""') DO (Call Set /A "LINE+=1" && (CMD /C "IF NOT "%%LINE%%" EQU "%~2" (if "%%B" EQU "" (Echo+>> "%~3.NEW") ELSE ((Echo %%B)>> "%~3.NEW")) ELSE (CALL SET "STRING=%%B" &&     (if "%%B" EQU "" (Echo+>> "%~3.NEW") ELSE ((CALL ECHO %%STRING:%~4=%~5%%)>> "%~3.NEW")))"))) && (CALL :RENAMER "%~3") & (GOTO:EOF)
  96. :RSA
  97. (For /F "tokens=1* delims=]" %%A in ('type "%~2" ^| find /n /v ""') DO (CALL SET "STRING=%%B" && (if "%%B" EQU "" (Echo+>> "%~2.NEW") ELSE ((CALL ECHO %%STRING:%~3=%~4%%)>>"%~2.NEW")))) && (CALL :RENAMER "%~2") & (GOTO:EOF)
  98. :C+
  99. (For /F "usebackq tokens=*" %%@ in ("%~3") DO (Call Set   "LINE=%%@" && (CALL ECHO %%LINE:~%~2%% >>      "%~3.NEW"))) && (CALL :RENAMER "%~3") & (GOTO:EOF)
  100. :C-
  101. (For /F "usebackq tokens=*" %%@ in ("%~3") DO (Call Set   "LINE=%%@" && (CALL ECHO %%LINE:~0,-%~2%% >>   "%~3.NEW"))) && (CALL :RENAMER "%~3") & (GOTO:EOF)
  102. :L+
  103. (Call SET /A "A=%~2") && (Call TYPE "%~3" |@MORE +%%A%% > "%~3.NEW") && (CALL :RENAMER "%~3") & (GOTO:EOF)
  104. :L-
  105. (For /F "tokens=1* delims=]" %%A in ('type "%~3" ^| find /n /v ""') DO (CALL SET /A "TOTAL_LINES+=1")) & (CALL SET /A "TOTAL_LINES-=%~2-1") & (For /F "tokens=1* delims=]" %%A in ('type "%~3" ^| find /n /v ""') DO (Call Set /A "LINE+=1" & Call echo "%%LINE%%!!|@%%TOTAL_LINES%%" >NUL) && (CALL :RENAMER "%~3" && GOTO:EOF) || (Echo %%B >> "%~3.NEW"))
  106. :GL
  107. (Call SET /A "A=%~2" && Call SET /A "A-=1") && (Call TYPE "%~3" |@MORE +%%A%% > "%temp%\getline.tmp") && (For /F "tokens=1* delims=]" %%A in ('type "%temp%\getline.tmp" ^| find /n /v ""') DO ((if "%%B" EQU "" (Echo+>> "%~3.NEW") ELSE ((Echo %%B)> "%~3.NEW"))) && ((CALL :RENAMER "%~3") & (GOTO:EOF)))
  108. :GR
  109. (For /F "tokens=1* delims=]" %%A in ('type "%~4" ^| find /n /v ""') DO (Call Set /A "LINE+=1" && (CMD /C "(IF "%%LINE%%" GEQ "%~2" IF "%%LINE%%" LEQ "%~3" (if "%%B" EQU "" (Echo+>> "%~4.NEW") ELSE ((Echo %%B)>> "%~4.NEW"))) && (IF "%%LINE%%" EQU "%~3" Exit /B 1)" || ((CALL :RENAMER "%~4") & (GOTO:EOF)))))
  110.  
  111. :RENAMER
  112. (REN "%~1" "%~nx1.BAK") & (MOVE /Y "%~1.BAK" "%TEMP%\" >NUL) & (REN "%~1.NEW" "%~nx1") & (GOTO:EOF)
8865  Programación / Scripting / Re: Cambiar el nombre inicial de Archivos con nombres similares en: 12 Junio 2013, 05:25 am
Código:
FOR %%@ IN ("%userprofile%\Desktop\6 documento Mayo\*%Pattern%*.%FileExt%")
8866  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 11 Junio 2013, 21:51 pm
Entonces este IniReader usa Secciones?
No, no lee secciones ni tampoco guarda secciones, no me gustan las secciones ni tampoco las considero útiles, menos para aplicaciones grandes como CCleaner.

explicame, como hago para llamar a 2 pcbs desde el mismo .INI :silbar: ;D

Pues primero guardas el valor de cada PictureBox en el ini, y luego obtienes los valores préviamente guardados y los asignas a... a lo que estés intentando asignarlo.

Lee los comentarios al principio de la Class, ahí hay ejemplos, no sé que puede resultar tán dificil (de verdad), crea un post porque si con esos ejemplos no te aclara entonces ya no se que más decir.

Saludos!
8867  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 11 Junio 2013, 19:59 pm
Cargar o guardar valores fácilmente en un archivo INI:

Código
  1. #Region " INI Manager "
  2.  
  3. ' [ INI Manager Functions ]
  4. '
  5. ' // By Elektro H@cker
  6. '
  7. ' Examples :
  8. '
  9. ' INI_Manager.Set_Value(".\Test.ini", "TextValue", TextBox1.Text) ' Save
  10. ' TextBox1.Text = INI_Manager.Load_Value(".\Test.ini", "TextValue") ' Load
  11. ' INI_Manager.Delete_Value(".\Test.ini", "TextValue") ' Delete
  12. ' INI_Manager.Sort_Values(".\Test.ini") ' Sort INI File
  13.  
  14. Public Class INI_Manager
  15.  
  16.    ''' <summary>
  17.    ''' The INI File Location.
  18.    ''' </summary>
  19.    Public Shared INI_File As String = IO.Path.Combine(Application.StartupPath, Process.GetCurrentProcess().ProcessName & ".ini")
  20.  
  21.    ''' <summary>
  22.    ''' Set a value.
  23.    ''' </summary>
  24.    ''' <param name="File">The INI file location</param>
  25.    ''' <param name="ValueName">The value name</param>
  26.    ''' <param name="Value">The value data</param>
  27.    Public Shared Sub Set_Value(ByVal File As String, ByVal ValueName As String, ByVal Value As String)
  28.  
  29.        Try
  30.  
  31.            If Not IO.File.Exists(File) Then ' Create a new INI File with "Key=Value""
  32.  
  33.                My.Computer.FileSystem.WriteAllText(File, ValueName & "=" & Value, False)
  34.                Exit Sub
  35.  
  36.            Else ' Search line by line in the INI file for the "Key"
  37.  
  38.                Dim Line_Number As Int64 = 0
  39.                Dim strArray() As String = IO.File.ReadAllLines(File)
  40.  
  41.                For Each line In strArray
  42.                    If line.ToLower.StartsWith(ValueName.ToLower & "=") Then
  43.                        strArray(Line_Number) = ValueName & "=" & Value
  44.                        IO.File.WriteAllLines(File, strArray) ' Replace "value"
  45.                        Exit Sub
  46.                    End If
  47.                    Line_Number += 1
  48.                Next
  49.  
  50.                Application.DoEvents()
  51.  
  52.                My.Computer.FileSystem.WriteAllText(File, vbNewLine & ValueName & "=" & Value, True) ' Key don't exist, then create the new "Key=Value"
  53.  
  54.            End If
  55.  
  56.        Catch ex As Exception
  57.            MsgBox(ex.Message)
  58.        End Try
  59.  
  60.    End Sub
  61.  
  62.    ''' <summary>
  63.    ''' Load a value.
  64.    ''' </summary>
  65.    ''' <param name="File">The INI file location</param>
  66.    ''' <param name="ValueName">The value name</param>
  67.    ''' <returns>The value itself</returns>
  68.    Public Shared Function Load_Value(ByVal File As String, ByVal ValueName As String) As Object
  69.  
  70.        If Not IO.File.Exists(File) Then
  71.  
  72.            Throw New Exception(File & " not found.") ' INI File not found.
  73.            Return Nothing
  74.  
  75.        Else
  76.  
  77.            For Each line In IO.File.ReadAllLines(File)
  78.                If line.ToLower.StartsWith(ValueName.ToLower & "=") Then Return line.Split("=").Last
  79.            Next
  80.  
  81.            Application.DoEvents()
  82.  
  83.            Throw New Exception("Key: " & """" & ValueName & """" & " not found.") ' Key not found.
  84.            Return Nothing
  85.  
  86.        End If
  87.  
  88.    End Function
  89.  
  90.    ''' <summary>
  91.    ''' Delete a key.
  92.    ''' </summary>
  93.    ''' <param name="File">The INI file location</param>
  94.    ''' <param name="ValueName">The value name</param>
  95.    Public Shared Sub Delete_Value(ByVal File As String, ByVal ValueName As String)
  96.  
  97.        If Not IO.File.Exists(File) Then
  98.  
  99.            Throw New Exception(File & " not found.") ' INI File not found.
  100.            Exit Sub
  101.  
  102.        Else
  103.  
  104.            Try
  105.  
  106.                Dim Line_Number As Int64 = 0
  107.                Dim strArray() As String = IO.File.ReadAllLines(File)
  108.  
  109.                For Each line In strArray
  110.                    If line.ToLower.StartsWith(ValueName.ToLower & "=") Then
  111.                        strArray(Line_Number) = Nothing
  112.                        Exit For
  113.                    End If
  114.                    Line_Number += 1
  115.                Next
  116.  
  117.                Array.Copy(strArray, Line_Number + 1, strArray, Line_Number, UBound(strArray) - Line_Number)
  118.                ReDim Preserve strArray(UBound(strArray) - 1)
  119.  
  120.                My.Computer.FileSystem.WriteAllText(File, String.Join(vbNewLine, strArray), False)
  121.  
  122.            Catch ex As Exception
  123.                MsgBox(ex.Message)
  124.            End Try
  125.  
  126.        End If
  127.  
  128.    End Sub
  129.  
  130.    ''' <summary>
  131.    ''' Sorts the entire INI File.
  132.    ''' </summary>
  133.    ''' <param name="File">The INI file location</param>
  134.    Public Shared Sub Sort_Values(ByVal File As String)
  135.  
  136.        If Not IO.File.Exists(File) Then
  137.  
  138.            Throw New Exception(File & " not found.") ' INI File not found.
  139.            Exit Sub
  140.  
  141.        Else
  142.  
  143.            Try
  144.  
  145.                Dim Line_Number As Int64 = 0
  146.                Dim strArray() As String = IO.File.ReadAllLines(File)
  147.                Dim TempList As New List(Of String)
  148.  
  149.                For Each line As String In strArray
  150.                    If line <> "" Then TempList.Add(strArray(Line_Number))
  151.                    Line_Number += 1
  152.                Next
  153.  
  154.                TempList.Sort()
  155.                IO.File.WriteAllLines(File, TempList)
  156.  
  157.            Catch ex As Exception
  158.                MsgBox(ex.Message)
  159.            End Try
  160.  
  161.        End If
  162.  
  163.    End Sub
  164.  
  165. End Class
  166.  
  167. #End Region
8868  Programación / .NET (C#, VB.NET, ASP) / Re: Scroll de Imagenes? en: 11 Junio 2013, 18:47 pm
Citar

Si no recuerdo mal creo que ese efecto se denomina "Bubble Fish" o "Eye Fish" (Ojo de péz),
lo puedes hacer como te ha dicho syntax error.

Solo tienes que averiguar el índice de la que es la imágen "central", porque si no la identificas primero, no puedes hacer nada, y entonces ya con esa imágen haces lo que prefieras, o bien usar eventos (mouse hover) para agrandar la imágen cuando se pase el ratón por la imágen, o bien mantenerla agrandada permanéntemente.

Saludos
8869  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 11 Junio 2013, 11:56 am
Otro código de ORO:

Devuelve de la manera más eficaz y sencilla una lista de tipo FileInfo con todos los archivos de un directorio,
Le hice dos overloads para poder usar la función de varias maneras y evitar posibles errores en el "SearchPattern",
La función es "IgnoreCase", devuelve la extensión en uppercase y lowercase y todas las variantes posibles, en fin, esto es la perfección:

Código
  1. #Region " Get Files "
  2.  
  3.    ' [ Get Files Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    '
  9.    ' For Each file In Get_Files("C:\Windows", False) : MsgBox(file.Name) : Next
  10.    '
  11.    ' For Each file In Get_Files("C:\Windows", True, "dll")   : MsgBox(file.Name) : Next
  12.    ' For Each file In Get_Files("C:\Windows", True, ".dll")  : MsgBox(file.Name) : Next
  13.    ' For Each file In Get_Files("C:\Windows", True, "*.dll") : MsgBox(file.Name) : Next
  14.    '
  15.    ' For Each file In Get_Files("C:\Windows", False, {"dll", "ini"})     : MsgBox(file.Name) : Next
  16.    ' For Each file In Get_Files("C:\Windows", False, {".dll", ".ini"})   : MsgBox(file.Name) : Next
  17.    ' For Each file In Get_Files("C:\Windows", False, {"*.dll", "*.ini"}) : MsgBox(file.Name) : Next
  18.  
  19.    ' Get Files {directory} {recursive}
  20.    Private Function Get_Files(ByVal directory As String, ByVal recursive As Boolean) As List(Of IO.FileInfo)
  21.        Dim searchOpt As IO.SearchOption = If(recursive, IO.SearchOption.AllDirectories, IO.SearchOption.TopDirectoryOnly)
  22.        Return IO.Directory.GetFiles(directory, "*", searchOpt).Select(Function(p) New IO.FileInfo(p)).ToList
  23.    End Function
  24.  
  25.    ' Get Files {directory} {recursive} {ext}
  26.    Private Function Get_Files(ByVal directory As String, ByVal recursive As Boolean, ext As String) As List(Of IO.FileInfo)
  27.  
  28.        If ext.StartsWith("*") Then
  29.            ext = ext.Substring(1, ext.Length - 1)
  30.        ElseIf Not ext = "*" AndAlso Not ext.StartsWith(".") Then
  31.            ext = ("." & ext)
  32.        ElseIf ext = "*" Then
  33.            ext = Nothing
  34.        End If
  35.  
  36.        Dim searchOpt As IO.SearchOption = If(recursive, IO.SearchOption.AllDirectories, IO.SearchOption.TopDirectoryOnly)
  37.        Return IO.Directory.GetFiles(directory, "*" & ext, searchOpt).Select(Function(p) New IO.FileInfo(p)).ToList
  38.  
  39.    End Function
  40.  
  41.    ' Get Files {directory} {recursive} {exts()}
  42.    Private Function Get_Files(ByVal directory As String, ByVal recursive As Boolean, ParamArray exts() As String) As List(Of IO.FileInfo)
  43.  
  44.        Dim FileExts(exts.Count) As String
  45.        Dim ExtCount As Int32 = 0
  46.  
  47.        For Each ext In exts
  48.            If ext.StartsWith("*") Then
  49.                FileExts(ExtCount) = ext.Substring(1, ext.Length - 1)
  50.            ElseIf Not ext = "*" AndAlso Not ext.StartsWith(".") Then
  51.                FileExts(ExtCount) = ("." & ext)
  52.            ElseIf Not ext = "*" AndAlso ext.StartsWith(".") Then
  53.                FileExts(ExtCount) = ext
  54.            ElseIf ext = "*" Then
  55.                FileExts(ExtCount) = Nothing
  56.            End If
  57.            ExtCount += 1
  58.        Next
  59.  
  60.        Dim searchOpt As IO.SearchOption = If(recursive, IO.SearchOption.AllDirectories, IO.SearchOption.TopDirectoryOnly)
  61.        Dim filenameExtComparer As New FilenameExtensionComparer
  62.        Return IO.Directory.GetFiles(directory, "*", searchOpt).Where(Function(o) FileExts.Contains(IO.Path.GetExtension(o), filenameExtComparer)).Select(Function(p) New IO.FileInfo(p)).ToList
  63.  
  64.    End Function
  65.  
  66.    ' FilenameExtensionComparer
  67.    Public Class FilenameExtensionComparer : Implements IEqualityComparer(Of String)
  68.  
  69.        Public Function Equals1(s As String, t As String) As Boolean Implements IEqualityComparer(Of String).Equals
  70.            Return String.Compare(s, t, StringComparison.OrdinalIgnoreCase) = 0
  71.        End Function
  72.  
  73.        Public Function GetHashCode1(s As String) As Integer Implements IEqualityComparer(Of String).GetHashCode
  74.            Return s.GetHashCode()
  75.        End Function
  76.  
  77.    End Class
  78.  
  79. #End Region
8870  Programación / Scripting / Re: Transformar nombre de los archivos a 001,002,003.png,etc? en: 11 Junio 2013, 09:57 am
perdón, lo escribí al vuelo y cometí un misstype, símplemente añade un SET /A aquí:
Código:
set /A num+=1

PD: La costumbre de no usar keywords a la izquierda de las variables en otros lenguajes cada vez se apodera más de mi xD.

Error:

Código
  1. Ya existe un archivo con el mismo nombre
  2. o no se ha encontrado el archivo.

Ese error que comentas es "normal", si ya tienes un archivo que se llama "1.png" no se puede renombrar al mismo nombre y el bat fallará con ese archivo, pero nada grave.

Saludos
Páginas: 1 ... 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 [887] 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 ... 1236
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines